Skip to content
Plaintools

Base64 encode & decode

Encode text, JSON, tokens, and files to Base64 or decode Base64 back to plain text and binary files entirely in your browser. Features complete UTF-8 Unicode support for international characters and emojis (avoiding browser btoa Latin-1 crashes), RFC 4648 §5 URL-safe alphabet conversion (- and _ instead of + and /), customizable line wrapping (64 chars for PEM certificates, 76 chars for MIME email), and client-side file encoding to Data URLs and HTML snippets. Nothing leaves your browser.

100% Client-Side EncodingRuns locally in your browser. Neither text nor uploaded files leave your computer.
Wrap:
Sample:
41 chars (41 B)
56 chars (56 B)

Base64 encode & decode example

Encoding UTF-8 payload with emoji and URL-safe characters

Text 'Hello, 世界! 🌍' encodes cleanly via UTF-8 bytes to 'SGVsbG8sIOS4lueVjCEg8J+Mjg==', with instant one-click toggle to URL-safe format and copy.

Base64 encode & decode how-to

  1. If encoding text: convert UTF-8 string to byte array using TextEncoder (preserving multi-byte Unicode and emojis).
  2. Convert bytes to binary string and apply base64 encoding (btoa or Buffer).
  3. If URL-safe is selected, replace '+' with '-' and '/' with '_', and adjust padding.
  4. If line wrapping is enabled, insert line breaks at 64 or 76 characters.
  5. If decoding text: strip whitespace and line breaks, restore '+' and '/' if URL-safe, restore padding '=', and decode bytes with TextDecoder.
  6. If processing file: read client-side using FileReader as Data URL or ArrayBuffer, emitting raw Base64, data URI, or decoded binary file.

Related tools

Dev

JWT decoder

Read a JWT header and payload, with human timestamps and an expired flag. The token stays in the tab.

Dev

Text diff checker

Compare two texts with a live line and word diff. Optional ignore-whitespace.

Dev

Hash generator

Calculate SHA-256, SHA-384, SHA-512, and SHA-1 checksums for text or local files.

Dev

Password generator

Generate strong, cryptographically secure random passwords with customizable length and character sets client-side.

Dev

UUID generator

Generate RFC 4122 compliant UUID v4 (random) and UUID v1 (timestamp-based) identifiers with bulk generation and formatting options.

People also use

Dev

Timestamp converter

Convert Unix epoch timestamps in seconds or milliseconds to ISO 8601, UTC, and local time.

Dev

CSV to JSON converter

Convert CSV records to a JSON array of objects with header mapping and type detection.

Base64 encode & decode FAQ

Does this Base64 tool send my data or files to any server?
No. All encoding and decoding happen directly inside your browser tab using JavaScript TextEncoder, TextDecoder, and FileReader APIs. Your strings and files never leave your computer.
Why do some online Base64 encoders fail on emojis and foreign languages?
The standard JavaScript btoa() function only supports ASCII / Latin-1 characters (character codes 0-255) and throws an InvalidCharacterError when encountering Unicode characters. Plaintools encodes text into UTF-8 bytes first using TextEncoder, ensuring all international alphabets and emojis encode and decode flawlessly.
What is URL-safe Base64 (RFC 4648 §5)?
Standard Base64 uses the plus sign (+) and slash (/), which have special meaning in URL query strings and path segments. URL-safe Base64 replaces '+' with '-' and '/' with '_', and often omits trailing padding '=' characters so the string can be safely placed in URLs and JSON Web Tokens (JWTs).
Can I convert local files and images to Base64 data URLs?
Yes. In the 'File to Base64' tab, you can drag and drop any image, document, audio, or binary file. The tool generates raw Base64, complete data URIs (data:image/png;base64,...), and ready-to-paste HTML img or CSS background-image snippets.
Can I decode Base64 back into a downloadable file?
Yes. When converting in file mode or decoding a file data URL, you can download the reconstructed binary data directly to your computer as a local file.
How do I encode Base64 in JavaScript without btoa Latin-1 errors?
Use TextEncoder and TextDecoder: const bytes = new TextEncoder().encode(str); const b64 = btoa(String.fromCharCode(...bytes)); To decode: const bytes = Uint8Array.from(atob(b64), c => c.charCodeAt(0)); const str = new TextDecoder().decode(bytes).
Is Base64 a form of encryption?
No. Base64 is a binary-to-text encoding format designed to transmit binary data over text-based protocols (like HTTP and email). Anyone can decode Base64 instantly without a key. Do not use Base64 to secure sensitive passwords or credentials.