ModernCalcs

Base64 ↔ JSON

Encode JSON to Base64 or decode a Base64 string back to formatted JSON. Useful for JWT payloads, API tokens, and encoded config values.

JSON → Base64

JSON Input

Base64 Output

ewogICJ1c2VyIjogImFsaWNlIiwKICAicm9sZSI6ICJhZG1pbiIsCiAgImV4cCI6IDE3MzU2ODk2MDAKfQ==

Base64 ↔ JSON: Inspect Encoded Payloads Instantly

Base64-encoded JSON appears in JWT tokens, API authorization headers, webhook secrets, and configuration blobs. This tool decodes them back to readable JSON or encodes any JSON payload to Base64 for embedding in URLs and headers.

Formula
Encode: JSON.stringify(obj) → UTF-8 bytes → btoa() → Base64 string Decode: atob(b64) → UTF-8 bytes → JSON.parse() → formatted JSON

UTF-8 multi-byte characters are handled via encodeURIComponent/unescape so non-ASCII JSON string values encode and decode correctly.

Where Base64 JSON Appears

JWT tokens use Base64URL (a variant) to encode their header and payload sections. Kubernetes secrets store values as Base64. Some APIs use Base64-encoded JSON in Authorization headers or as query parameters when the JSON would otherwise break URL encoding. CI systems like GitHub Actions and GitLab CI store Base64-encoded config blobs in repository variables.

Standard Base64 vs Base64URL

This tool uses standard Base64 (characters +, /, = for padding). JWT uses Base64URL, which substitutes - for + and _ for / and omits padding. If you are trying to decode a JWT payload (the middle section between the two dots), use the JWT Decoder tool instead — standard Base64 decoding will produce incorrect output for Base64URL-encoded strings.

Validation on Both Sides

When encoding, the input is validated as JSON before encoding — this prevents silently encoding malformed JSON that would fail when decoded by an API. When decoding, the output is validated as JSON and pretty-printed. If the Base64 decodes to something that is not valid JSON, an error is shown rather than garbled output.

Practical Examples

Inspecting a Kubernetes Secret Value

Kubernetes stores secret values as Base64. Decode to see the actual config.

  • 1.Run: kubectl get secret my-secret -o jsonpath='{.data.config}'
  • 2.Paste the Base64 output into this tool's input
  • 3.Select 'Decode' direction
  • 4.The JSON config is displayed formatted and readable

How the Encoding Works

  • Input JSON validated before encoding
  • UTF-8 encoding handles non-ASCII characters correctly
  • Standard Base64 (+ / =), not Base64URL
  • Decoded output pretty-printed with 2-space indent

Good Use Cases

  • Inspecting Base64-encoded Kubernetes or Docker secrets
  • Decoding CI/CD variable blobs containing JSON config
  • Encoding JSON payloads for Authorization headers or query params
  • Debugging API tokens that carry Base64-encoded JSON claims

Frequently Asked Questions

How is this different from a plain Base64 encoder?

This tool validates that the decoded Base64 is valid JSON and pretty-prints the result. Encoding also validates that the input is valid JSON before encoding. A plain Base64 tool treats the payload as arbitrary text.

Is this safe for JWT payloads?

JWT uses Base64URL encoding (- instead of +, _ instead of /), not standard Base64. This tool uses standard Base64. For JWT decoding, use the JWT Decoder tool.

Does this handle Unicode characters in JSON?

Yes. The encoder uses UTF-8 encoding via encodeURIComponent/unescape to handle non-ASCII characters in JSON string values before Base64 encoding.