What This Tool Does
This tool converts between JSON and Base64 in a single input box, and it figures out which direction you need automatically — there is no encode/decode switch to set. When you click Run, it first tries to parse your input as JSON. If that succeeds, it Base64-encodes the JSON string. If the input isn't valid JSON, it assumes you pasted Base64 text, decodes it, and pretty-prints the result as JSON with 2-space indentation.
The encoding step is UTF-8 safe: it runs your JSON string through encodeURIComponent before btoa, so accented characters, CJK text, and emoji all encode and decode correctly. A plain btoa() call would throw an error on any of those, since it only understands single-byte Latin1 characters.
How to Use It
- Paste your JSON object or array — or a Base64 string — into the Input box above.
- Click Run.
- If you pasted valid JSON, the Base64-encoded string appears in the Output box.
- If you pasted Base64, the decoded, pretty-printed JSON appears in the Output box instead.
- If something goes wrong — malformed JSON that also isn't valid Base64, for example — an error message appears below the boxes instead of a result.
- Click Clear to reset both boxes and start over.
Worked Example
Given this JSON input:
{"id":1,"name":"Alice"}
The tool detects it as valid JSON and produces this Base64 output:
eyJpZCI6MSwibmFtZSI6IkFsaWNlIn0=
Paste that Base64 string back into the input and run it again, and the tool decodes it back to the original JSON, pretty-printed with 2-space indentation.
Common Use Cases
- Passing JSON in a URL or query parameter — raw JSON contains braces, quotes, and colons that aren't URL-safe, while Base64 output is plain alphanumeric text (plus a few safe symbols).
- Storing structured data in text-only fields — some databases, config values, cookies, or legacy APIs only accept plain strings, so encoding a JSON object to Base64 lets it travel through as one opaque string.
- Inspecting the payload of a JWT — the middle segment of a JSON Web Token is a Base64url-encoded JSON payload, so this tool is useful for decoding it to read the claims (though it does not create, sign, or verify tokens).
- Debugging encoded API responses or logs — quickly decode a Base64 blob you find in a log line or response body to see the underlying JSON.
Frequently Asked Questions
Is Base64 encoding the same as encryption?
No. Base64 is an encoding scheme, not encryption — anyone can decode a Base64 string back to plain text in one line of code. It provides zero confidentiality. If your JSON contains sensitive data, encrypt it before encoding; don't rely on Base64 to hide the contents.
Does this work with Unicode and emoji in my JSON?
Yes. The encoder is UTF-8 safe, so accented letters, CJK text, and emoji all round-trip correctly instead of throwing the InvalidCharacterError you'd get from a plain btoa() call.
Is my data uploaded anywhere?
No. All encoding and decoding happens locally in your browser using JavaScript. Nothing you paste into this tool is sent to a server.
How does the tool know whether to encode or decode?
It tries to parse your input as JSON first. If that succeeds, it Base64-encodes it. If parsing fails, it treats the input as Base64 and attempts to decode and pretty-print it as JSON instead. There's no manual switch to toggle.
Can I use this for JWT tokens?
You can use it to encode or decode the JSON payload portion of a JWT, but it does not create, sign, or verify JWTs — full JWT handling requires a header, a signature, and a secret or key, which this tool doesn't manage.
Related Tools & Guides
- Browse all JSON tools
- Base64 Encoding JSON: When and Why You'd Actually Need It — a deeper guide covering the UTF-8-safe encode/decode pattern and common pitfalls.
- JSON Formatter / Prettifier
- Minify JSON Online