JSON to Base64 Encoder

Validate a JSON document, choose its whitespace, then encode the exact UTF-8 bytes as Base64 without sending the payload away.

Reviewed & Maintained by Wajahat QasimLast updated July 27, 2026

UTF-8 browser encoder

Encode the bytes your receiver expects

Whitespace changes the Base64 result. Pick a mode before copying.

JSON treatment

JSON source

Objects, arrays, strings, numbers, booleans, or null.

Waiting
0 lines0 characters0 UTF-8 bytes

Base64 text

Standard alphabet with padding where required.

Waiting
0 characters0% size change

The first misconception

Base64 is packaging, not protection

A Base64 string looks scrambled, yet anyone with a decoder reads the original JSON. No password, secret key, or encryption step exists in this format.

Use Base64 where a text-only field must carry arbitrary UTF-8 bytes. Do not use it to hide API keys, session tokens, customer records, or payment data. Sensitive payloads still need transport encryption, access control, plus storage rules suited to the data.

A real packet

One webhook body, three valid outputs

Suppose a retry queue stores this event for invoice INV-2048:

{"event": "invoice.paid","amount": 49.95,"currency": "EUR"}

Preserve mode encodes every visible line break plus indentation space. Compact mode parses the document, then serializes one line before encoding. Format mode produces stable two-space indentation first. All three decode to valid JSON with equal values. Their Base64 strings differ because their source bytes differ.

Alphabet
A-Z, a-z, 0-9, +, /
Padding
Zero, one, or two = marks
Text encoding
UTF-8 before Base64
Data security
None. The operation reverses without a key.

Whitespace has a byte cost

Preserve, compact, or format?

The receiving parser usually ignores JSON whitespace. Signature checks, cache keys, snapshot tests, plus byte-for-byte comparisons do not. Choose from the destination backward.

ModeBest fitTrade-off
PreserveSigned payloads, archived source, forensic comparisonExtra spaces increase output length
CompactHeaders, query-safe handoffs, storage fieldsOriginal layout disappears
FormatExamples, tickets, readable fixturesProduces the largest form

When another team supplied the source, preserve mode is the cautious choice. When you own both ends of a simple text field, compact mode wastes fewer bytes. Open the JSON Beautifier first if the source needs a careful syntax review beyond one parse error.

Inside this tab

Parse first. Encode second.

The page reads your input with JSON.parse(). Invalid syntax stops the operation, so malformed data never receives an apparently successful Base64 wrapper. Compact or format mode then runs JSON.stringify(). Preserve mode retains the source text after validation.

Next, TextEncoder turns the chosen text into UTF-8 bytes. Base64 groups those bytes in sets of three, converts each group into four six-bit values, then maps the values to its 64-character alphabet. A final group shorter than three bytes receives = padding.

This route matters for names such as Zoë, prices such as ₹799, or emoji inside message fields. Older shortcuts built around btoa() alone reject characters outside Latin-1. UTF-8 conversion prevents that failure.

Where encoded JSON earns its keep

Text-only boundaries in real systems

Queue metadata

A broker attribute might permit text while the event body lives elsewhere. Encoding a small JSON descriptor preserves punctuation without inventing a custom delimiter. Check the broker's field-size limit first.

Legacy form fields

An older endpoint might accept one string value but still need a structured object. Base64 avoids quote escaping inside the field. URL encoding remains separate, so use the URL Encoder if the string enters a query parameter.

Test fixtures

A fixture might mirror an upstream service whose contract stores encoded bodies. Keep the decoded JSON beside the test or document the generation mode. Otherwise a future diff becomes difficult to review.

Command-line handoff

Base64 removes braces plus quotation marks from the payload, which reduces shell quoting trouble. Shell length limits still apply. For large documents, a file path is cleaner than a giant argument.

Need to inspect the result later? The Base64 to JSON decoder reverses this workflow. Use the JSON Minifier when compact JSON, rather than Base64, meets the receiving contract.

Where this page stops

Size, variants, plus signatures

Base64 usually adds about one third to the byte count before padding. A 3,000-byte JSON document becomes roughly 4,000 Base64 characters. Encoding a large export inside a browser tab duplicates data in memory, so files measured in tens of megabytes belong in a streaming script or command-line program.

  • The output uses standard Base64. JWTs plus some URLs expect Base64url, where + becomes -, / becomes _, plus padding often disappears.
  • The page validates JSON values. Comments, trailing commas, undefined, or JavaScript object syntax fail parsing.
  • Encoding does not compress data. Compress first only when both systems agree on the compression format.
  • Never reformat a payload before checking a byte-level signature. Even one removed space changes the digest.

Questions at the encoding boundary

Practical answers about UTF-8, whitespace, output size, privacy, plus Base64 variants.

Why did formatting change my Base64 string?

Base64 represents bytes, including spaces plus line breaks. Formatting changes those bytes even though a JSON parser reads the same values after decoding.

Does this encoder support emoji or non-Latin text?

Yes. The source passes through UTF-8 before encoding, so emoji, accented names, Arabic, CJK text, plus currency symbols retain their original characters after decoding.

Does Base64 make JSON smaller?

No. Standard Base64 grows data by roughly one third. Compact mode removes optional JSON whitespace first, which reduces the source, but Base64 itself is not compression.

Is the output suitable for a JWT segment?

Not without conversion. JWT segments use Base64url, a related alphabet with URL-safe characters plus usually no equals padding.

Does Toolexe store the pasted JSON?

No. Validation, UTF-8 conversion, Base64 encoding, copy, plus download stay inside the browser tab.