Base64 Encoder & Decoder
Two-way Base64 encoder and decoder in your browser. Converts UTF-8 text (including non-ASCII characters and emojis) to Base64 strings via TextEncoder and btoa(), or decodes Base64 payloads back to UTF-8 text via atob() and TextDecoder with malformed-input error validation.
How to Use Base64 Encoder & Decoder
Click **Encode to Base64** or **Decode from Base64** at the top and type or paste your string into the left input box (`Plain Text to Encode` or `Base64 String to Decode`). To handle accented letters, non-Latin scripts, and emojis accurately without `Character Out Of Range` exceptions, the encoder first converts your string into a UTF-8 byte array via `new TextEncoder().encode()` before applying `btoa()`, while the decoder strips whitespace, runs `atob()`, and reconstructs UTF-8 characters via `new TextDecoder().decode()`. If a pasted string in Decode mode contains non-Base64 characters or corrupted padding, an error alert (`Invalid Base64 string`) appears immediately. Click **Swap** to flip the output into the input box and switch modes, or click **Copy** to copy the result. **Important:** Base64 is a reversible binary-to-text encoding scheme used for data transport—it is **not encryption or password protection**, and anyone can decode a Base64 string without a secret key. For URL query escaping or JSON formatting, see our URL Encoder & Decoder and JSON Formatter.
- 1
Choose Encode to Base64 or Decode from Base64
Select Encode to Base64 to convert plain text into Base64, or Decode from Base64 to read an encoded string.
- 2
Type or Paste Your Input String
Enter plain UTF-8 text, JSON, or a Base64 string into the left textarea (character count updates live).
- 3
Inspect Live Output or Format Errors
View the converted output in the right box, or check the error banner if a Base64 string is malformed.
- 4
Click Swap or Copy Result
Click Swap to reverse the conversion direction with your current output, or click Copy to copy to clipboard.
Encoding Default UTF-8 Text With Em-Dash Punctuation Into Base64
TextEncoder converts multibyte UTF-8 characters (like the 3-byte em-dash "—") into raw bytes before Base64 radix-64 mapping.
38 characters (40 UTF-8 bytes because "—" is 3 bytes: 0xE2 0x80 0x94).
new TextEncoder().encode(str) (40 bytes) → 6-bit Base64 groups with "=" padding.
Reversible via Decode from Base64 (TextDecoder restores the exact UTF-8 string).
Related Free Tools
Explore more browser-based tools in Daily & Text Utilities or browse the complete All Tools Directory.
Percent-encode URLs and query string parameters or decode %XX escaped URLs online using encodeURIComponent or encodeURI.
Format, beautify, validate, and minify JSON online with 2-space or 4-space indentation, syntax error alerts, copy, and .json download.
Generate RFC 4122 Version 4 UUIDs (GUIDs) in batches of 1, 5, 10, or 25 with uppercase and hyphen formatting toggles.
Generate random passwords from 6 to 64 characters with uppercase, lowercase, number, symbol, and ambiguous-character controls.