Base64 Encoder & Decoder
Encode and decode text and files as Base64. Images get a preview and a ready-made data URI, and decoded output is identified by its content so it saves with the right extension.
What Base64 does
Base64 is a way to write arbitrary bytes using only text characters. It turns 3 bytes into 4 characters, so that places which can only hold text — JSON values, HTML attributes, email bodies, cookies — can carry an image or a file as-is.
It is not encryption. Reversing it needs no key, so never use it to hide anything. It is a container for moving values, nothing more.
Size grows by roughly 1.33×, because 3 bytes become 4 characters.
Non-ASCII text survives
The browser's built-in btoa() assumes one character is one byte. Give it 한 or é and it throws instead of returning a value.
This tool converts text to UTF-8 bytes first, then encodes those bytes. Korean, Japanese, and emoji come back exactly as you put them in.
Decoding identifies the format
A base64 string does not say what it is. Unlike a file it has no name and no type — it is a blob of characters.
This tool tries three things in order.
- If it arrived as a data URI like
data:image/png;base64,, the declared type is used. The prefix is stripped automatically, so there is no need to delete it by hand - The signature at the start of the bytes is read. PNG begins with
89 50 4E 47, PDF with%PDF-, and so on — most formats carry their own marker - If the bytes read as UTF-8, the content is inspected. JSON, XML, HTML, and SVG have no signature, so an opening brace or tag decides
That is why decoding a PDF saves as .pdf and JSON as .json. Only when all three fail do you get .bin.
Anything recognised as an image gets a preview.
You do not choose the variant
Base64 has variants. For URLs, + and / already mean something else, so they become - and _, and the trailing = is often dropped. JWT works this way.
Encoding always produces standard base64. But decoding accepts any variant. Where a value was copied from is not something the person pasting it gets to choose.
Limits
Files up to 20 MB. Beyond that the base64 runs past 27 MB of characters, which the browser cannot hold comfortably.
Image previews up to 2 MB. Building a preview means turning the picture back into characters and holding a second copy on screen. Larger files still encode fine — you just do not see the picture.
Results longer than 500,000 characters are drawn only in part. But copy and save always use the whole thing — the value is not truncated, only the view is.
Two ways to add a file
Drop it on the source box, or use Choose file at its top right.
One file at a time. Drop several and the first one is used, and the tool says so.