Base64 exists to carry bytes through something that only handles text, which is why it turns up in data URLs, mail attachments, JSON Web Tokens, and any configuration format that has to hold a whole document inside a single string value.
The bug most browser Base64 tools have
The browser’s built-in btoa function refuses anything above code point
U+00FF. The moment your JSON contains an accented letter, a currency
symbol, or an emoji, btoa throws, which is why so many quick Base64
tools break the instant real world text touches them.
Using the JSON to Base64 converter
This tool encodes to UTF-8 bytes first, which is what every other language and every server does, so the result matches what a backend would produce for the same document. Encoding
{"name":"café","price":"₹500","clef":"𝄞"}
produces a Base64 string that decodes, through the browser’s own standard
atob and TextDecoder, back to the exact original document: café,
₹500 and the musical symbol 𝄞 all survive, including that last
character, which needs a surrogate pair in JavaScript and four bytes in
UTF-8.
Three failures, told apart
Decoding can go wrong in three genuinely different ways, and lumping them together as “invalid input” hides which one you are looking at:
- Not Base64 at all. A character outside the Base64 alphabet is named
directly:
This is not Base64: "!" is not a Base64 character, with the position. - Valid Base64, but the bytes are not text. The string decodes fine as bytes, but those bytes are not valid UTF-8, which usually means you have Base64 of a binary file rather than of a document.
- Valid text, but not JSON. The Base64 decoded perfectly into a string, and that string is not a JSON document, reported with the same kind of message the formatter and validator give for broken JSON.
What forms it accepts
Decoding tolerates a data: URL prefix, line breaks inside the Base64
text, and the URL safe alphabet that substitutes - and _ for + and
/. Paste a data URL you copied from a browser’s network tab directly; the
prefix is stripped automatically.
Is this encryption
No. Base64 is an encoding, not a cipher. Anyone can decode it with a single line of code in any language, including by pasting it into this same tool in the other direction. It is for making bytes safe to carry through a text-only channel, not for keeping them secret.