"category": "format-converter",

JSON to Base64 Encoder

"tldr": Paste JSON to validate and Base64-encode it in one step - UTF-8 safe, ready for headers, secrets, and environment variables.

Validate and encode a JSON document as Base64 in one step. Base64-encoded JSON is everywhere in modern infrastructure: HTTP headers that cannot carry raw JSON, Kubernetes secrets, environment variables in CI systems, JWT payloads, and webhook signatures.

{"json": "base64"}

The tool validates your JSON before encoding - so you never ship a Base64 blob containing a syntax error - and handles UTF-8 correctly, meaning non-ASCII characters and emoji encode and decode without corruption.

How to encode JSON as Base64

  1. 1Paste your JSON into the input panel.
  2. 2The tool validates the syntax first and reports any error before encoding.
  3. 3Valid JSON is UTF-8 encoded and converted to a Base64 string.
  4. 4Copy the result into your header, secret, or environment variable.

Convert JSON to Base64 in code

Python
import base64, json

payload = {"service": "payments-api", "debug": False}
encoded = base64.b64encode(json.dumps(payload).encode()).decode()
print(encoded)
JavaScript
const payload = { service: "payments-api", debug: false };
const bytes = new TextEncoder().encode(JSON.stringify(payload));
const encoded = btoa(String.fromCharCode(...bytes));

Frequently asked questions

Why Base64-encode JSON at all?

To move JSON through channels that cannot carry it raw: HTTP header values, URL parameters, environment variables with strict quoting, XML documents, or binary-safe fields. Base64 turns the payload into a single safe ASCII token at the cost of ~33% size overhead.

Is Base64 encryption?

No - it is an encoding, not encryption, and anyone can decode it instantly. Never treat Base64 as protection for secrets. If confidentiality matters, encrypt the payload and then Base64-encode the ciphertext.

Does this handle unicode correctly?

Yes. The JSON is encoded as UTF-8 bytes before Base64 conversion, which is the convention every decoder expects. Naive JavaScript btoa() on raw strings corrupts non-ASCII characters - this tool avoids that pitfall.

Is this how JWTs are built?

Almost - JWTs use Base64url, a URL-safe variant that swaps + for -, / for _, and drops padding. If you are constructing a JWT segment, apply those substitutions to the output, or use a JWT library which handles it all.

Last updated:

You might also need

Free and in-browser, like everything on JSON Console. Browse all tools →