Base64 encode and decode
How to encode or decode Base64
- Choose Encode to Base64 or Decode from Base64.
- Paste your text into the first box. The result appears a moment after you stop typing.
- When encoding, set the URL-safe alphabet, the = padding and a line length (76 for MIME, 64 for PEM) as the target system needs.
- Press Copy result. Use result as input and switch makes the result the new input and flips the mode, so you can check a round trip.
- If decoded data is not text, the page says so and offers Download decoded bytes.
Base64 is an encoding, not encryption
Base64 writes bytes with 64 printable characters: A to Z, a to z, 0 to 9, + and /. It has no key and no secret, so anyone can decode it, and so can this page. Use it to carry bytes through text-only places such as email, JSON or a URL, not to hide a password.
Every 3 bytes become 4 characters, so the result is a third bigger. Our five language samples grew by 33.3 to 35.4 percent, the extra coming from the = signs. Those pad the last group: one leftover byte gives two = signs and two bytes give one. Ma became TWE=, Man became TWFu and Many became TWFueQ==.
Accents, emoji and line breaks
The page encodes the UTF-8 bytes of your text. We ran English, Chinese, Japanese, Arabic and Thai samples and a line with accents and emoji. Each result matched Node's Buffer and decoded back to the same text. The emoji 🙂 became 8J+Zgg==.
Half an emoji on its own (a lone surrogate) cannot become UTF-8, and the page refuses it with its code.
Line breaks in the box count as one byte. A text typed with Windows CRLF breaks (20 bytes) was encoded as 18 bytes, 24 characters, because the box turns each CRLF into a single line feed. If you need the CRLF bytes, for a signature or a hash, the Base64 will not match.
URL-safe, padding and line length
Standard Base64 uses + and /, which mean something in web addresses. The URL-safe form uses - and _ instead. For ~~~???>>>üÿ the page gave fn5+Pz8/Pj4+w7zDvw== as standard and fn5-Pz8_Pj4-w7zDvw== as URL-safe. With padding off it gave fn5-Pz8_Pj4-w7zDvw, the same as Node's base64url output. The decoder accepts the = signs or their absence.
Mail systems want lines of 76 characters (MIME) and PEM files want 64. A 381-byte text came out as 7 lines at 76, the last one 52 characters, and 8 lines at 64, the last one 60. There is no break at the end, and decoding ignores breaks.
Decoding: what it accepts and what it refuses
The decoder ignores spaces, tabs and line breaks anywhere in the text. It drops a leading data:text/plain;base64, header, reads both alphabets and accepts missing = signs: SGk gave Hi. It refuses the rest with a message that names the cause:
SGVs$bG8=: a character outside the alphabet. A dot does the same, so a three-part token with dots must be split and each part decoded alone.SGVsb: five characters is not a possible length.SG=k,SGk===andSGVsbA=: = in the wrong place or the wrong number of them.SG+k_w: both alphabets in one string.
Empty input gives an empty result and no message.
Not every valid string is text. /+8= decodes to two bytes that are not UTF-8, so the page shows nothing garbled. It says how many bytes there are and offers Download decoded bytes, which saved exactly those two bytes as decoded.bin. A 21,105-byte PNG pasted as Base64 downloaded with an identical SHA-256, but the page does not show images and the file needs renaming. The word test is valid Base64 too, and decodes to 3 bytes that are not text.
Large text
We pasted plain text of 1, 5, 10 and 20 MB, encoded it and decoded it back. Every result was exact. Encoding and decoding took 0.5 and 0.8 seconds for 1 MB, 3.9 and 4.3 for 5 MB, and 10.2 and 8.9 for 10 MB. At 20 MB the browser tab crashed in our test.
What stays in the browser
With outside connections blocked, we encoded a text holding a unique marker, decoded its Base64 and copied the result. The page made 12 requests, two of them outside scripts (the Google ad script and the Google tag, blocked in the test). None carried a body or named the marker or its Base64. Browser storage stayed empty.
Related tools
To turn an image into Base64 or a data URI, use the image to Base64 page. Percent-encoding for web addresses is a different encoding, and the URL encode and decode page does it. Base64 is not a checksum: to check a download, use the file hash checker.
Measured results
| Test | What we ran | What came out |
|---|---|---|
| Five language samples | Encode, then decode | Same as Node; decoded text identical; 33.3 to 35.4 percent bigger |
| Text with CRLF breaks | Encode | 18 bytes encoded, not 20: CRLF became LF |
| M, Ma, Man, Many | Encode with and without padding | TQ==, TWE=, TWFu, TWFueQ== (padding off: TQ, TWE, TWFu, TWFueQ) |
| 381-byte text | Wrap at 76 and at 64 | 7 lines (last 52) and 8 lines (last 60), no final break, decodes back |
| 22 decode inputs | Paste each in decode mode | 11 decoded, 7 refused with a message, 2 not text, 2 empty |
| 1, 5, 10 MB text | Encode, then decode | 0.5 and 0.8 s, 3.9 and 4.3 s, 10.2 and 8.9 s; 20 MB crashed the tab |
| Network test | Encode, decode, copy a marker | 12 requests, 2 outside, 0 bodies, 0 naming the marker, storage empty |
Prefer desktop software?
A command line suits files and bulk work: base64 on Linux and macOS, certutil on Windows, or PowerShell. We did not test them. OpenSSL has openssl base64, and Python has base64.
Frequently asked questions
Is Base64 encryption?
No. It has no key, and anyone can decode it, including with this page. It only changes how bytes are written. If a secret must stay secret, encrypt it first.
What is URL-safe Base64?
It swaps + and / for - and _ so the text can sit in a web address or file name. Tick the box when encoding. Decoding reads both forms, but a mixed string is refused.
Why does decoding say the data is not text?
The bytes are not valid UTF-8, so showing them would give garbage. They may be an image, a file or encrypted data. Download decoded bytes saves them exactly as decoded.bin.
Is my text uploaded?
No. In our test the page's own code sent no request that carried the text, and browser storage stayed empty.
Can I decode a token with dots?
Not whole. The dots are outside the Base64 alphabet, so the page refuses the string. Split it at the dots and decode each part separately. The page does not verify signatures.