JSON to Base64 Encoder – Free

Paste a JSON document and get it as standard Base64. This JSON to Base64 encoder parses the input first and refuses invalid JSON, then encodes your original text without reformatting it.

How to use the JSON to Base64 tool

  1. Paste the document into the JSON box, or select Example to load {"hello":"world"}.
  2. Select Encode. The tool parses the text to confirm that it is valid JSON.
  3. If parsing fails, read the parser message under the Result box, fix the problem it describes and encode again.
  4. Select Copy to take the Base64 string from the Result box.

How the JSON to Base64 encoder works

The tool runs two stages. First it hands your text to the browser's JSON parser, which enforces the grammar of RFC 8259: double-quoted keys and strings, no trailing commas, no comments. If the parser throws, nothing is encoded.

Second, it encodes the text you typed, not the parsed value. The string is converted to UTF-8 and then to Base64 with padding. Whitespace, key order and duplicate keys are left alone and the box is not trimmed, so decoding returns your document character for character. Top-level values other than objects, such as 42, null or a quoted string, are valid JSON and are accepted.

A worked example

The compact object is 17 bytes and encodes to 24 characters with one = sign. Adding a single space after the colon makes it 18 bytes, and the two results agree only in their first 13 characters. If a system compares or signs the encoded value, formatting differences count.

Both strings begin with eyJ. The bytes for an opening brace and a double quote always produce ey, and a key that starts with a letter makes the third character J. That is the reason JSON Web Tokens are recognizable at a glance.

{"hello":"world"}   ->  eyJoZWxsbyI6IndvcmxkIn0=
{"hello": "world"}  ->  eyJoZWxsbyI6ICJ3b3JsZCJ9

Why validation fails

The error text comes from your browser's parser, so the wording differs between browsers. These are the causes behind most messages.

  • Single quotes around keys or strings. JSON allows double quotes only.
  • Unquoted keys, as in a JavaScript object literal.
  • A trailing comma after the last property or array element.
  • Comments, which are not part of the JSON grammar.
  • Values such as NaN, Infinity or undefined.
  • An empty box, reported as an unexpected end of input.

Where Base64 JSON appears

JSON Web Tokens carry a JSON header and payload, each written in Base64URL without padding as RFC 7515 requires. Kubernetes stores registry credentials as Base64 JSON under the .dockerconfigjson key of a Secret. Push messages from queue services commonly deliver a JSON payload in a Base64 data field, and web apps pack small JSON objects into cookies or state parameters.

This tool writes standard Base64 with padding. For a token segment or a URL parameter, convert the result with the Normalize Base64 tool set to URL-safe, unpadded.

Frequently asked questions

Does the tool minify or reformat my JSON before encoding?

No. Parsing is only a validity check. The bytes that get encoded are the exact characters in the box, including indentation and line breaks. Minify the document yourself first if you want the shortest result.

Why do Base64 JSON strings start with eyJ?

An object begins with a brace and a double quote. Those two bytes, plus the top bits of the first letter of the key, always map to the characters eyJ. Arrays and other values start differently.

Can I use the output as a JWT header or payload?

Not directly. A JWT segment uses the URL-safe alphabet with the padding removed, and a real token also needs a signature computed over both segments. Convert the alphabet with Normalize Base64 and sign with a JWT library.

Is the JSON I paste sent to a server?

No. Parsing and encoding run in your browser. That said, Base64 hides nothing, so treat an encoded document that contains secrets with the same care as the plain one.

How do I decode the result back to JSON?

Open the Base64 to JSON tool on this site and paste the string. It decodes the bytes, checks that they are valid JSON and prints the document with two-space indentation.

Related tools