Skip to content
XUtilHub

JSON to Base64 Encoder Online

Encode JSON to Base64 (standard or URL-safe), with full UTF-8 support. Optionally minify first. Free and private.

  • Free, no sign-up
  • Runs in your browser, nothing uploaded
Input
Output

About the JSON to Base64

Encode JSON as a Base64 string for HTTP headers, URLs, tokens or environment variables. It handles Unicode correctly, and can produce URL-safe output.

Key features

  • Encodes JSON as standard Base64 or URL-safe Base64URL
  • Correct UTF-8 handling for emoji and non-Latin text
  • Optional minification first for shorter output
  • Validates the JSON before encoding
  • Instant results as you type
  • Runs locally; safe for secrets and tokens

Why encode JSON as Base64?

Base64 turns any data into a string made only of letters, digits and a couple of symbols. That makes JSON safe to place where special characters such as quotes, braces and line breaks would cause trouble:

  • HTTP headers. Custom headers can't contain line breaks and often choke on quotes.
  • URLs and query strings. Base64URL output can be dropped straight into a link.
  • Environment variables. Store a JSON config in a single env var without escaping.
  • Kubernetes secrets and CI/CD variables, which are commonly Base64-encoded.
  • Tokens. JWT headers and payloads are Base64URL-encoded JSON.
  • Data attributes and cookies, where quotes must be avoided.

Example

{"user":"ada","role":"admin"}
ModeOutput
Standard Base64eyJ1c2VyIjoiYWRhIiwicm9sZSI6ImFkbWluIn0=
URL-safe Base64URLeyJ1c2VyIjoiYWRhIiwicm9sZSI6ImFkbWluIn0

Standard vs. URL-safe

Base64Base64URL
CharactersA–Z a–z 0–9 + /A–Z a–z 0–9 - _
Padding= at the endUsually omitted
Use in URLsNeeds percent-encodingSafe as-is
Used byEmail (MIME), data URIs, KubernetesJWT, OAuth, URL parameters

Doing it in code

// Browser / Node.js (UTF-8 safe)
const b64 = btoa(String.fromCharCode(...new TextEncoder().encode(JSON.stringify(data))));
# Shell
echo -n '{"user":"ada"}' | base64

Important: Base64 is not security

Base64-encoded data looks scrambled but isn't protected: decoding takes milliseconds. Don't use it to hide passwords or API keys from users.

Decode with Base64 to JSON. Inspect tokens with the JWT Decoder. Encode images with Image to Base64.

How to use the JSON to Base64

  1. Paste your data into the input box, upload a file, or click Sample to try it out.
  2. Adjust the options above the editor if you need to (indentation, delimiter, and so on).
  3. The Base64 appears instantly in the output panel. Any errors are shown with their line and column.
  4. Click Copy to copy the result, or Download to save it as a file.

Frequently asked questions

Is Base64 encryption?

No. Base64 is an encoding, not encryption. Anyone can decode it instantly. Never use it to protect secrets; use proper encryption instead.

What is URL-safe Base64?

Base64URL replaces + with - and / with _ and drops = padding, so the result can be used in URLs, file names and JWTs without extra escaping.

Why is the Base64 output bigger than my JSON?

Base64 represents every 3 bytes with 4 characters, so output is about 33% larger. Minifying the JSON first reduces the final size.

Why do some online tools break emoji?

The browser's btoa function only accepts Latin-1 characters. This tool encodes the text as UTF-8 bytes first, so emoji, accents and non-Latin scripts survive the round trip.

Is my JSON uploaded to a server?

No. All JSON tools run entirely in your browser, so your data never leaves your device.

Is there a size limit?

There is no fixed limit. Files of several megabytes work fine; very large files depend on your device's memory.

Do I need an account?

No. Every JSON tool is free and works without signing up.

Last updated:

Related JSON tools