Base64 encoder and decoder that survives accents and emoji
Convert text to Base64 and back as you type, switch to the URL-safe alphabet used in JWTs, and turn a file into a data URL without it leaving your machine. Text is encoded through UTF-8 first, so “café” comes out as Y2Fmw6k= instead of throwing the error most browser-based tools hand you. Nothing is uploaded or saved.
- Nothing is uploaded or saved
- Works offline
Q2Fmw6kg4piVIOKAlCB0aGUgYWNjZW50IGlzIHdoeSBidG9hKCkgYWxvbmUgZmFpbHMgaGVyZS4=
Reads the file in this page with the browser’s own file reader and writes it as “data:<type>;base64,…”. Nothing is uploaded. Best kept for icons and small SVGs — see the FAQ below for when inlining is the wrong call.
How it works
- 1
Pick a direction
Text to Base64, or Base64 back to text. Both run on every keystroke — there is no Encode button, because watching the output change as you edit is the whole reason to open a page instead of reaching for a terminal.
- 2
Choose the alphabet
Standard Base64 uses “+” and “/” for its last two characters and pads the end with “=”. The URL-safe alphabet swaps those for “-” and “_” and drops the padding, because “+” means a space to form decoders and “=” has to be written “%3D” inside a URL. When decoding, you do not have to choose: both alphabets are accepted, and missing padding is tolerated, so a segment copied out of a JWT decodes as it stands.
- 3
Or drop in a file
Any file can become a data URL — “data:image/png;base64,…” — which is a complete, self-contained copy of the file written as text. The file is read by your browser, in this page, and the bytes never travel anywhere.
- 4
Read the error, not a blank box
Broken Base64 gets a sentence naming the problem: a character that is not in either alphabet, padding in the middle of a value, or a length that cannot work. Valid Base64 that decodes to non-text bytes is reported as such rather than shown as a wall of replacement characters.
Frequently asked questions
Is Base64 encryption? Can I use it to hide something?
No, and this matters more than any other answer on this page. Base64 is a way of writing bytes using 64 characters that survive email, URLs and config files — it has no key and no secret. Anyone who sees the string can decode it in one step, including with this page. Putting a password or an API key in Base64 makes it unreadable to a human skimming a file and completely readable to anyone who cares. If it needs to stay secret, it needs encryption, not encoding.
Why does btoa() fail on “café” and this page does not?
btoa() only accepts characters in the Latin-1 range, so anything with an accent, any CJK text and every emoji throws InvalidCharacterError. Base64 encodes bytes, and a JavaScript string is not bytes — it has to be turned into them first. This page runs the text through TextEncoder to get UTF-8 bytes and encodes those. “café” is five UTF-8 bytes (63 61 66 C3 A9) and comes out as Y2Fmw6k=, which you can paste back into the decoder above to check.
How much larger does Base64 make my data?
Every three bytes become four characters, so about a third larger, rounded up to a multiple of four. A 1,000-byte file becomes 1,336 characters: 333 whole groups give 1,332, and the single leftover byte takes a fourth group padded with “==”. That overhead is why Base64 belongs on small things and not on a 4 MB photo.
What is a data URL, and when should I not use one?
A data URL carries the file inside the URL itself — “data:image/png;base64,iVBORw0…” — so a page can show an image with no second request. It is a genuine win for a 200-byte icon or an inline SVG. It is a poor trade above a few kilobytes: the string sits in your HTML or CSS, so it is a third larger than the file, it cannot be cached separately, it blocks the parser while it is read, and it cannot be swapped for a smaller format later. As a rule, inline what is too small to be worth a request and link everything else.
Why does my JWT segment have no “=” at the end?
JWTs use base64url (RFC 4648 §5), which drops padding entirely — the length of the original data can be worked out from the length of the encoded string, so the padding carries no information. It also swaps “+” and “/” for “-” and “_” so the value can sit in a URL or a header without being escaped again. Paste a segment in and it decodes as it is; the padding is added back internally.
Can I decode a Base64 image or PDF here?
It will decode to the correct bytes, but this page will tell you the result is not text rather than printing it. That is deliberate: showing a few thousand replacement characters looks like the tool is broken. If you have a full data URL for an image, the file panel above is the right half of the tool.
Does anything I paste leave my browser?
No. The encoder and decoder are written in the JavaScript this page already loaded, and there is no upload of any kind — including for files, which are read locally with the browser’s own file reader. Nothing is written to localStorage either, so closing the tab is enough to leave nothing behind.