Convert JSON to Base64
Standard, URL-safe
and code snippets.
Encode any JSON to Base64 online — standard or URL-safe. Minify before encoding. Get JavaScript, Python, Node.js and Java code snippets. Runs entirely in your browser.
Why encode JSON as Base64?
Common use cases where Base64-encoded JSON is the right approach.
URL query parameters
JSON contains characters that are unsafe in URLs — {"key":"value"} becomes a broken URL. Encoding to Base64 (URL-safe) produces a single clean string safe for query parameters, path segments and anchor hashes — no additional percent-encoding needed.
JWT payloads
JSON Web Tokens (JWTs) use Base64url encoding for their header and payload sections. The payload is a JSON object Base64url-encoded and joined with dots. Understanding the encoding is essential when debugging JWTs — decode the middle section to inspect the claims.
HTTP headers and configs
Some HTTP headers and API authentication schemes pass JSON configurations as Base64-encoded values. Kubernetes secrets, Basic Auth credentials and some webhook configurations use Base64 to safely embed structured data in header values or environment variables.
CLI tools and environment variables
Passing complex JSON to CLI tools or storing it in environment variables (which cannot contain newlines or special characters) is much cleaner with Base64 encoding. The entire JSON config becomes a single safe string that any shell or CI/CD system can handle.
Standard Base64 vs URL-safe Base64
Two variants — choose based on where you use the encoded string.
| Standard Base64 | URL-safe Base64 (Base64url) | |
|---|---|---|
| Characters | A–Z, a–z, 0–9, +, / | A–Z, a–z, 0–9, -, _ |
| Padding | = added | = stripped |
| Safe in URLs | No — + becomes space, / is path separator | Yes — safe in query params and path segments |
| Use for | File encoding, data storage, email attachments | JWT, URL params, filenames, Kubernetes secrets |
| RFC | RFC 4648 §4 | RFC 4648 §5 |
All utilities & encoding tools
JSON encoded in your
browser. No upload.
The entire encoding runs in JavaScript using the browser's native btoa() function. Your JSON is never sent to any server. URL-safe encoding replaces + with - and / with _ following RFC 4648 §5, and strips the = padding.
The code snippets show the idiomatic approach for each language — Buffer.from() in Node.js, base64.b64encode() in Python, and Base64.getEncoder() vs getUrlEncoder() in Java.
