JSON to Base64

Encode JSON to Base64 or decode Base64 back to formatted JSON.

0 chars
0 words
0 lines
0 chars
0 words
0 lines

JSON to Base64 Encoder with Validation

This tool encodes JSON documents to Base64 and decodes Base64 back to nicely formatted JSON. Unlike a generic text encoder, it understands JSON: the input is validated before encoding, it can be minified on the fly, and decoded output is pretty-printed with two-space indentation so you can read it immediately.

Where Base64 JSON shows up

JSON is often wrapped in Base64 when it has to travel through a channel that doesn't like braces, quotes, or line breaks. Common examples are JSON Web Token payloads, the state parameter in OAuth redirects, Kubernetes and Docker config values (for example .dockerconfigjson in an image pull secret), webhook signatures, message queue payloads, GraphQL cursors, and cookies that store small session objects. Decoding these by hand is tedious; paste the string here and you get readable JSON back.

Minify and pretty-print

With Minify JSON first enabled, { "a": 1, "b": [1, 2] } is compacted to {"a":1,"b":[1,2]} before encoding, giving you the shortest possible Base64. When decoding, Pretty-print result re-indents the JSON; switch it off to see the exact text that was encoded, including its original whitespace.

Example

The minified object {"user":"ayse","admin":false} encodes to eyJ1c2VyIjoiYXlzZSIsImFkbWluIjpmYWxzZX0=. Notice that it begins with eyJ, the Base64 form of {". When you spot a string starting with eyJ in logs or headers, it's almost certainly Base64-encoded JSON.

Other options

URL-safe output, padding control, MIME line wrapping, and data:application/json;base64, data URIs are all supported. You can also open a .json file directly. Need to escape JSON for a string literal instead of encoding it? Use JSON Escape / Unescape. For general text, see Text to Base64.

Frequently Asked Questions

Yes. The input is parsed with JSON.parse before encoding. If there is a trailing comma, a single-quoted string, or a missing bracket, you get the parser's error message instead of Base64, so broken JSON never ends up in your config or request.

Usually yes when the Base64 goes into a header, URL, or environment variable. Removing indentation and line breaks can shrink the payload by 20–40%, and the decoded data is still the same object. Keep the original formatting only if you need a human-readable diff of the decoded text.

The Base64 decoded fine, but the result is not JSON. It may be plain text, a JWT segment that was truncated, or a compressed payload. Turn to Text to Base64 to see the raw decoded text, or check whether the data is gzip-compressed first.

JWT headers and payloads are JSON encoded with Base64URL and without padding. Enable URL-safe and disable padding here to reproduce a JWT segment. Remember that the signature, not the encoding, is what protects a token.