Base64 Is Not Encryption: How It Works and Why
Short answer: Base64 turns bytes into plain text so they can travel through systems that only handle text, such as JSON, email headers and URLs. It is an encoding, not encryption: anyone can decode it, so it protects nothing. Use the Base64 Encoder & Decoder to convert both ways. It handles Unicode as UTF-8 and supports the URL-safe variant.
What Base64 does
Base64 writes every 3 bytes as 4 characters from a 64-letter alphabet: A-Z, a-z, 0-9, + and /, with = used as padding at the end. Two consequences follow:
- The output is about a third larger than the input. That is the price of using only safe text characters.
- It is fully reversible without any key. There is no secret, so there is no security.
This is why a password "hidden" in Base64, an API key in a config file or a token in a URL is not hidden at all (if one has already leaked, see what to do about a leaked API key). If something must stay secret, encrypt it or, for passwords, hash it properly (see MD5 vs SHA-256 vs SHA-3 vs BLAKE2).
A quick example
Hello, 世界 encodes to SGVsbG8sIOS4lueVjA==. The text is converted to UTF-8 bytes first, which is why accented letters, emoji and other scripts survive the round trip.
URL-safe Base64 (Base64url)
The standard alphabet uses + and /, which have special meanings in URLs and file names. URL-safe Base64 swaps them for - and _ and usually drops the = padding. The value ???>>> becomes Pz8_Pj4- instead of Pz8/Pj4+.
You meet this variant all the time. Each part of a JSON Web Token is Base64url, which is why you can read a token's header and claims without a key, and why that proves nothing about the token (see the JWT Decoder Guide). The encoder has a URL-safe tick box, and the decoder accepts either form.
Decoding problems and what they mean
"Not valid Base64". The text contains characters outside A-Z a-z 0-9 + / - _ =, or its length cannot be Base64. Usual causes: a stray quote, or a data URL prefix such as data:image/png;base64,. Remove the prefix and decode only the part after the comma.
"Not valid UTF-8 text". The Base64 is fine, but it decodes to binary bytes, such as an image or a compressed file. The converter shows text only. To turn an image file into a Base64 data URL, use Image to Base64. To inspect raw bytes, use the Hex Viewer.
Missing padding or line breaks. Missing = signs and line breaks, as in MIME-wrapped email Base64, are accepted when decoding, so you do not need to clean them first.
When Base64 is a sensible choice
- Embedding a small image or font in CSS or HTML as a data URL.
- Putting binary data into JSON, which has no binary type.
- Email attachments and similar text-only channels.
- Carrying a signature or key in a header.
It is a poor choice for large files, because of the size growth, and never a choice for secrecy.
Base64 is not encryption: how to use the Base64 tool
- Open the Base64 Encoder & Decoder.
- Choose Encode or Decode.
- Type or paste. The result updates as you type.
- Tick URL-safe to use
-and_and to drop the padding.
Limits to know
- The tool deals with text. Binary input and output need the other tools linked above.
- Base64 is not a security measure of any kind.
- Everything runs in your browser. Nothing is uploaded.
Frequently asked questions
Is Base64 encryption? No. It is a reversible encoding, and anyone can decode it.
Why is Base64 bigger than the original? Every 3 bytes become 4 characters, so the data grows by about a third.
What is the difference between Base64 and URL-safe Base64?
URL-safe Base64 uses - and _ instead of + and /, and drops the = padding.
How do I decode a data URL?
Remove the data:…;base64, prefix and decode the part after the comma.
Is URL encoding the same as Base64? No. Percent-encoding keeps text readable inside a URL. Base64 changes the alphabet entirely.