JSON to Base64
Paste JSON and instantly get a Unicode-safe Base64 encoding of it.
Example
Encoding the JSON {"hi":"café"} first UTF-8 encodes it (note é becomes two bytes), then Base64-encodes the bytes:
Input: {"hi":"café"}
Output: eyJoaSI6ImNhZsOpIn0=How it works
The JSON text is UTF-8 encoded with TextEncoder, then the resulting bytes are Base64-encoded with btoa. Conversion runs live as you type and validates that the input is parseable JSON.
Good to know
JSON to Base64 takes whatever JSON you paste and returns its Base64 encoding, computing the bytes with the browser's TextEncoder (UTF-8) before running them through btoa. It is aimed at developers who need to embed a JSON payload somewhere that only accepts a single opaque string: an environment variable, a URL query parameter, a JWT-style claim, an HTML data attribute, a config field, or a request body that must travel through a text-only channel without breaking on quotes, newlines, or non-ASCII characters.
Reach for it when a raw JSON string would be mangled or rejected in transit. Base64 turns the payload into a compact alphabet of A-Z, a-z, 0-9, plus + and / with = padding, so it survives copy-paste, shell interpolation, and systems that choke on braces or line breaks. The trade-off is that the output is roughly one-third larger than the input and is not encryption — anyone can decode it back instantly, so never treat Base64 as a way to hide secrets.
To read the result, remember the two-step pipeline that produced it. Your text is first turned into UTF-8 bytes (so an accented or emoji character expands to multiple bytes), and those bytes are what get encoded. The status line reports the Base64 character count and, separately, whether your input actually parsed as JSON. A "not valid JSON" warning does not stop the encoding: the tool still encodes the exact text you typed, which is handy when you deliberately want to encode a fragment or a non-JSON string.
- This is standard Base64 with + and / — if your target needs URL-safe Base64, swap + to -, / to _, and strip the = padding after copying.
- The output decodes byte-for-byte, so encode-then-decode is lossless even with emoji, accents, or CJK text.
- Whitespace and formatting in your JSON are preserved, so pretty-printed and minified input produce different Base64 strings.
Frequently asked questions
Does it handle non-ASCII characters like emoji or accents?
Yes. The text is UTF-8 encoded with TextEncoder before Base64 encoding, so emoji, accents, and other Unicode characters are preserved correctly (plain btoa alone would fail on them).
Does it validate that my input is valid JSON?
It tries to parse the input as JSON and shows a warning if it is not valid, but it still encodes whatever text you provide so you can use it for arbitrary strings too.
Is my data uploaded anywhere?
No — it runs entirely in your browser. Your input never leaves your device and it works offline once loaded.
Is it free?
Yes, completely free with no sign-up and no limits.
People also ask
What is the difference between Base64 and JSON to Base64 encoding?
Base64 is a general scheme for representing any binary data as text; JSON to Base64 simply means you take a JSON string, convert it to UTF-8 bytes, and Base64-encode those bytes. The JSON itself is just the source text being encoded.
Does Base64 encoding make my JSON smaller?
No. Base64 increases size by about 33 percent because every three bytes of input become four output characters. It is used for safe transport and embedding, not compression.
How do I decode a Base64 string back into JSON?
Base64-decode the string to recover the original UTF-8 bytes, then read those bytes as text. In a browser you can use atob combined with TextDecoder, and a dedicated Base64 to JSON tool reverses the same pipeline automatically.
Why use TextEncoder instead of plain btoa for JSON?
btoa only handles characters in the Latin-1 range and throws an error on characters above code point 255, such as emoji or many accented letters. TextEncoder first converts the string to UTF-8 bytes so the full Unicode range encodes correctly.
Is Base64 encoding the same as encryption?
No. Base64 is a reversible encoding with no key, so anyone can decode it back to the original JSON. It provides no confidentiality and should never be used to protect passwords, tokens, or other secrets.
Can I put Base64-encoded JSON in a URL?
You can, but standard Base64 includes +, /, and = which have special meaning in URLs. For URLs, convert to URL-safe Base64 by replacing + with -, / with _, and removing the = padding, or percent-encode the string.
Does whitespace in my JSON change the Base64 output?
Yes. The tool encodes the exact text you provide, so spaces, indentation, and newlines are part of the input bytes. Minified and pretty-printed versions of the same data produce different Base64 strings.
Can I Base64-encode text that is not valid JSON?
Yes. The tool flags input that does not parse as JSON but still encodes whatever text you enter, so it works as a general-purpose UTF-8 to Base64 encoder for arbitrary strings.
Related tools