JSON to Base64

Validate a JSON document and encode it to Base64, ready for a token, a header or a queue message.

JSON
Base64
Runs locally in your browser

About the JSON to Base64

Encoding JSON before it travels solves a real problem: nested quotes stop fighting with the outer container. A configuration blob inside an environment variable, a state parameter in an OAuth redirect and a message body on a queue all become a single opaque token that no intermediate parser will try to reinterpret.

The document is parsed before anything is encoded, so a stray trailing comma or an unquoted key is caught here rather than on the far side of the wire, where the failure is much harder to trace. Minifying is on by default because whitespace you cannot see still costs bytes after the 33 percent Base64 expansion; switch it off when the receiving system diffs the exact text you wrote.

The URL-safe alphabet is the setting to reach for when the token lands in a query string, a cookie or a path segment, since it removes the padding and replaces the two characters that need percent-encoding. Wrapping at 64 or 76 characters produces the block layout used in PEM files and mail headers.

Remember that this is an encoding, not a protection: anyone can reverse it in a second, so signed tokens and real encryption are the answer for anything confidential. Clean up the document first with JSON Formatter, and read an encoded payload back with Base64 to JSON.

How to use

  1. Paste your JSON document into the left pane.
  2. Leave Minify before encoding ticked for the shortest output, or untick it to preserve your formatting.
  3. Tick URL-safe alphabet for a token, then copy the encoded string.

Common questions

Why does it refuse my JSON?
Because it is parsed first. Comments, trailing commas and single quotes are not part of JSON, and the error points at the exact line and column.
Does minifying change the data?
No. Only insignificant whitespace between tokens is removed, so the parsed value is identical.
Is this how a JWT payload is built?
The middle segment is built the same way, with the URL-safe alphabet and no padding. A real token also needs a header and a signature.
Can I encode a very large document?
Yes. The work happens in your browser, so the practical ceiling is available memory rather than an upload limit.