Base64 ⇄ JSON Encoder/Decoder

Encode JSON to Base64, or decode Base64 back to JSON — direction is auto-detected.

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

  1. Paste your JSON object or array — or a Base64 string — into the Input box above.
  2. Click Run.
  3. If you pasted valid JSON, the Base64-encoded string appears in the Output box.
  4. If you pasted Base64, the decoded, pretty-printed JSON appears in the Output box instead.
  5. 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.
  6. 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

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

Partner tools