JSON to Base64

Encode JSON to Base64 and decode it back. For token segments, use URL-safe Base64 instead.

0 characters

Example

The JSON {"id":7} encodes to eyJpZCI6N30=. In code you would do:

JavaScript
const json = JSON.stringify({ id: 7 });
const b64 = btoa(unescape(encodeURIComponent(json))); // "eyJpZCI6N30="
const back = JSON.parse(decodeURIComponent(escape(atob(b64))));

JSON to Base64 — FAQ

How do I Base64 encode JSON?+

Paste your JSON above and switch to Encode. The tool treats it as UTF-8 text and returns a Base64 string you can put in a header, URL or token.

Why Base64 encode JSON at all?+

To move JSON safely through channels that mishandle quotes, braces or newlines — for example inside a JWT payload, an HTTP header, or a URL parameter.

Does encoding JSON to Base64 keep it valid?+

Decoding returns the exact original JSON text, character for character, so it stays valid as long as your input was valid JSON.

Should I encode JSON for JWTs?+

JWTs use URL-safe Base64 (no padding). Use the URL-Safe Base64 tool for token segments rather than standard Base64.