How to use the JSON to Base64 Encoder
Encode JSON to Base64 in seconds:
1
Paste your JSON
Paste any valid JSON object, array, or string into the input panel.
2
Choose options
Toggle Minify before encoding for the smallest Base64 output, or Pretty-print for human-readable encoded JSON. Toggle URL-safe to replace + and / with - and _ for use in URLs.
3
Click Encode
Get the Base64-encoded string instantly, along with the original and encoded byte sizes.
4
Copy the result
Copy the Base64 string for use in your HTTP headers, env vars, URL parameters, or wherever you need it.
When to use this tool
Use this whenever you need to embed JSON in a context that requires plain-text or URL-safe encoding:
- →Encoding JSON payloads for HTTP Authorization headers (Basic Auth, custom auth schemes)
- →Embedding JSON configuration as a Base64 environment variable in Docker, Kubernetes secrets, or CI/CD variables
- →Creating data URIs (data:application/json;base64,...) with JSON content for browser-based applications
- →Manually encoding JWT header or payload sections for debugging or constructing test tokens
- →Encoding JSON for query parameters in URLs where raw JSON would cause parsing issues
- →Storing JSON values in systems that only accept plain string values without nested structure
Frequently asked questions
Q:Why would I encode JSON to Base64?
JSON contains characters like {, ", :, and newlines that can cause issues in HTTP headers, URL query parameters, environment variables, and some configuration systems that only accept plain strings. Base64 encoding converts JSON into a safe, compact string of alphanumeric characters that passes through any text-safe channel without escaping issues.
Q:Is the JSON minified before encoding?
By default, yes — JSON is minified (whitespace removed) before encoding to produce the smallest possible Base64 string. Toggle 'Pretty print before encoding' if you want readable, indented JSON encoded into Base64 instead. The encoded size difference can be significant for large JSON objects.
Q:What is URL-safe Base64?
Standard Base64 uses + and / which are special characters in URLs (+ means space, / separates path segments). URL-safe Base64 replaces these with - and _ which are safe in URLs and query strings without percent-encoding. Use URL-safe mode when the Base64 string will appear in a URL, cookie, or JWT token.
Q:How do I encode JSON for an HTTP Authorization header?
For HTTP Basic Auth, the format is Base64(username:password). For custom JSON auth schemes, encode your JSON object with this tool and prefix the result with your scheme name (e.g. Bearer <base64string>). Make sure to use URL-safe mode if the header value will be used in a URL context.
Q:Can I decode Base64 back to JSON?
Yes — use the Base64 to JSON Decoder tool on this site, which reverses this operation. It handles both standard and URL-safe Base64, and automatically pretty-prints the decoded JSON.
Q:Is my JSON data sent to a server?
No. All encoding happens client-side in your browser using native browser btoa() and TextEncoder APIs. No data leaves your machine — safe to use with sensitive credentials, API keys in config files, or personal data.