UTF-8 first, always
Korean, Japanese and emoji are turned into UTF-8 bytes before encoding, which is what browsers, JSON and servers expect. The latin1 habit that turns a sentence into mojibake is not on offer here.
Pikkola Base64, tool No. 29
Paste text, pick a format, read the result. Base64, URL-safe Base64, percent-encoding, hex and Unicode escapes all go both ways, and a dropped image comes out as a Data URI you can put into a stylesheet or an img tag. The work happens in the page, not on a server.
Text
The converter
Type or paste on the left and the right side follows on every keystroke. Turn the arrow around and the same box reads base64, percent, hex or escapes back into text. Input that will not decode is named in a sentence rather than turned into silent question marks.
Nothing is sent. The page's security policy blocks every other origin. ⌘⏎ swaps sides · ⌘⇧C copies the result
Files and data URIs
Drop an image or a small file and it comes out as a Data URI, ready for a stylesheet, an img tag or a Markdown link. Paste a Data URI back in to see the picture and save the file. The browser reads the file and never sends it anywhere.
Read with the FileReader API, encoded in this tab.
Same bytes, five wrappers.
Paste a data: URL or a bare base64 string. The type is read from the header, or guessed from the first bytes.
Nothing to show yet.
The five formats
The word hello, five ways. They carry the same bytes, and each one belongs somewhere different.
| Format | hello | Where it belongs | What to remember |
|---|---|---|---|
| Base64btoa / Buffer | aGVsbG8= |
JSON fields, mail attachments, tokens | A to Z, a to z, 0 to 9, plus and slash. Padding equals signs at the end. |
| Base64 URL-safeJWT, URL | aGVsbG8 |
URLs, file names, JSON Web Tokens | The same bytes with minus and underscore instead of plus and slash. Padding often dropped. |
| Percent-encodingencodeURIComponent | hello |
Query strings, form posts, link values | A space becomes %20. One UTF-8 byte above 0x7F becomes three characters like %EC%95%88. |
| Hexxxd, Wireshark | 68 65 6c 6c 6f |
Byte dumps, colour values, protocol logs | Two characters per byte. Case does not matter on the way in. |
| Unicode escape\uXXXX | \u0068\u0065\u006c\u006c\u006f |
JavaScript strings, JSON, properties files | One escape per UTF-16 unit, so an emoji takes two. The brace form writes it as one code point. |
Base64 is encoding, not encryption. It keeps bytes intact through a text channel and anyone can read it. If the string has to stay secret, encrypt it first. If you only need to know it has not changed, a hash is the shorter answer.
Why this one
Korean, Japanese and emoji are turned into UTF-8 bytes before encoding, which is what browsers, JSON and servers expect. The latin1 habit that turns a sentence into mojibake is not on offer here.
A base64 string of the wrong length, a stray character, an odd number of hex digits, bytes that are not UTF-8: each one is reported in a sentence, next to the box that caused it.
Decode is not a second page or a second tool. Turn the arrow around and the same text goes back, with padding and the URL-safe alphabet handled for you.
The text lives in the textarea and the file in memory. Reload and it is gone, which is the point when the string is a key, a token or a customer record. Two preferences are kept in local storage: the theme and the interface language.
Read the privacy noteQuestions
No. Base64 is a way to write bytes with 64 safe characters so they can travel through a text channel. Anyone holding the string can decode it in a second. If the text has to stay secret, encrypt it first. If you only need to know a file has not changed, a hash is the shorter answer.
Base64 turns every 3 bytes into 4 characters, about 33 percent more, and adds one or two padding characters at the end. Percent-encoding can triple a Korean or Japanese character, because each one is 3 bytes in UTF-8 and each byte becomes a %XX group.
Because they encode one character per byte. Korean, Japanese and emoji do not fit in a byte, so a latin1 encoder produces mojibake and the decode side cannot repair it. This tool converts the text to UTF-8 bytes first, which is what browsers, servers and JSON all expect.
The same bytes with the two characters that URLs dislike replaced: plus becomes minus and slash becomes underscore. The padding equals signs are often dropped, because a URL treats them as part of the path or query. JSON Web Tokens use this form.
When the string goes into a URL as a parameter or a path segment. Percent-encoding keeps the value readable and is what the URL standard defines. Base64 in a query string has to be percent-encoded anyway, because plus, slash and equals each mean something there.
Any size the browser can hold, but a Data URI is about a third larger than the file and sits inside the document, so it suits small things: an icon, a logo, a texture, a short sound. Past a few hundred kilobytes a normal file link is better, and this page shows the encoded size before you paste it anywhere.
No. The browser's own file reader reads them and the page converts them in memory. The content security policy blocks requests to every other origin, so there is no route out even if a mistake were made.
Yes. Encoding works on UTF-8 bytes, so an emoji is four bytes and comes back as one character. In the escape format it is written as a surrogate pair by default, or as a single \u{1F600} when the brace option is on.