Base64 Encoder & Decoder
Two-way text conversion, correct for UTF-8 and for the URL-safe alphabet.
How Base64 works, in numbers
Base64 takes three input bytes (24 bits) and re-splits them into four 6-bit groups, each mapped to one character of a 64-character alphabet. That is why the encoded size is always about 4/3 of the original — a 33 percent inflation — and why the output length is always a multiple of four, padded with = when the input is not a multiple of three bytes.
| Input bytes | Bits | Output chars | Padding |
|---|---|---|---|
| 3 | 24 | 4 | none |
| 2 | 16 | 4 | one = |
| 1 | 8 | 4 | two == |
The alphabet has two dialects
Standard Base64 uses + and /, which are unsafe inside a URL or a filename. Base64URL (RFC 4648 §5) substitutes - and _ and usually strips the padding. JWT, OAuth, and most modern APIs use Base64URL — if you decode a JWT segment with a standard decoder and see garbled output, the alphabet is the reason.
Three situations where Base64 is the right answer
- Binary inside a text container — JSON, XML and email cannot carry arbitrary bytes, so images, certificates and protobuf payloads are Base64-encoded first.
- Data URIs —
data:image/png;base64,...inlines a small icon directly into CSS or HTML, removing an HTTP request. - Transport through a legacy layer — SMTP and some SOAP stacks historically mangled 8-bit data, so MIME wraps Base64 at 76 characters per line.
What Base64 is not
Base64 is encoding, not encryption. Anyone can reverse it in one step, with no key. If you need confidentiality the payload must be encrypted first — and if you Base64-encode a secret in a config file, you have published it in a slightly less readable font.
Decoding things that fail
A decoder that returns an error is telling you something useful. Common causes: padding removed by a URL round-trip, + turned into a space by a form or query-string parser, the URL-safe alphabet being fed to a standard decoder, or a truncated paste. This tool accepts both alphabets and tolerates missing padding, which covers all four.
How to use it
- Paste your text, or paste a Base64 string to reverse it.
- Choose the alphabet — standard for files and MIME, URL-safe for tokens.
- Read the result; the byte count updates so you can see the 33 percent overhead.
Worth knowing
- Encoded output is always a multiple of four characters when padding is kept.
- Alphabet size is exactly 64, which maps cleanly onto six bits.
- Base64URL is defined in RFC 4648 §5 and drops padding in JWT usage.
- MIME Base64 inserts a line break every 76 characters, per RFC 2045.
Limitations
- Encoding adds 33 percent to the size — do not use it as compression.
- It provides zero confidentiality.
- Whitespace and newlines are ignored on decode, but stray characters will fail.
- Very large payloads are limited by available tab memory.
Frequently asked questions
How do I decode Base64 to an image?
data:image/png;base64,..., copy everything after the comma into the decoder here to inspect the bytes. To save it as a file, decode in your language of choice and write the bytes with the image extension the MIME type indicates.Why does my Base64 contain `-` and `_`?
- replaces + and _ replaces / so the string survives URLs and filenames. Decode it with the URL-safe alphabet here.Is Base64 the same as encryption?
Why does Base64 end with `=`?
==; one input byte needs three plus =. Some systems strip it, and strict decoders reject the shorter form.