Free JSON to Base64 — standard · URL-safe · code snippets

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.

Your data never leaves your browser
Standard + URL-safe encoding
JS · Python · Node · Java snippets
Always free
JSON to Base64 Encoder   100% client-side
JSON input
  Base64 ready

      

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 Base64URL-safe Base64 (Base64url)
CharactersA–Z, a–z, 0–9, +, /A–Z, a–z, 0–9, -, _
Padding= added= stripped
Safe in URLsNo — + becomes space, / is path separatorYes — safe in query params and path segments
Use forFile encoding, data storage, email attachmentsJWT, URL params, filenames, Kubernetes secrets
RFCRFC 4648 §4RFC 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.

btoa() native

Uses the browser's built-in btoa() — no library, no dependency, always available.

URL-safe RFC 4648

Correct RFC 4648 §5 implementation — replaces + and /, strips = padding.

5 language snippets

JS, Node.js, Python, Java and C# — both standard and URL-safe variants for each.

52 tools, always free

No watermarks, no account. Funded by non-intrusive display advertising only.

Frequently asked questions

How do I convert JSON to Base64 in JavaScript?

btoa(JSON.stringify(obj)) — but this fails for non-ASCII characters. Use btoa(unescape(encodeURIComponent(JSON.stringify(obj)))) for full Unicode support. In Node.js: Buffer.from(JSON.stringify(obj)).toString('base64'). Select the Code Snippets mode for the complete pattern with error handling.

What is the difference between Base64 and Base64url?

Standard Base64 (RFC 4648 §4) uses + and / which are unsafe in URLs. Base64url (RFC 4648 §5) replaces + with - and / with _, and strips the = padding — making it safe for URL parameters, JWT tokens and filenames without percent-encoding. Select URL-safe in the options above for Base64url output.

How do I decode Base64 back to JSON?

Use the Base64 to JSON tool. In JavaScript: JSON.parse(atob(base64String)). In Python: import json, base64; json.loads(base64.b64decode(s)). In Node.js: JSON.parse(Buffer.from(s, 'base64').toString()).

Is the JSON to Base64 encoder free?

Yes, completely free. No account required. JSONSwitcher is funded by non-intrusive display advertising.

How do I convert JSON to Base64 in Python?

import base64, json; base64.b64encode(json.dumps(obj).encode("utf-8")).decode() — use base64.urlsafe_b64encode for the URL-safe variant.
Go up