JSON to Base64 Converter Online
JSON to Base64 encoder that checks your JSON parses before encoding it, plus a decoder that strips a data: URI prefix and returns the JSON pretty-printed.
Input
Output
What Is JSON to Base64?
Sometimes you need to embed a JSON payload somewhere that only accepts plain text: an HTTP header, a query parameter, a config file value, or a JWT claim. Base64 is the standard way to do that: it turns arbitrary bytes into a safe ASCII string. This tool lets you go either direction: paste JSON and get Base64, or paste Base64 and get back the original JSON, pretty-printed and ready to read.
The encoding is done locally by the page itself, with the standard btoa() and atob() APIs, so the payload you paste is never uploaded anywhere. The mode buttons flip the direction: Encode takes JSON to Base64, Decode takes Base64 back to JSON.
How to Use This Tool
Choose Mode
Choose the direction with the two mode buttons. Encode reads JSON and returns one Base64 line; Decode reads Base64, or a full data:application/json;base64,... URI, and returns indented JSON. Switching modes redoes the conversion with the text you already have on the left.
Paste Input
Paste into the left editor. Encode works on your text exactly as typed, so a pretty-printed object produces a longer string than the same object minified; squash it first if the value is headed for an HTTP header. Sample loads a small object, or its Base64 form in Decode mode, and Upload reads a .json or .txt file.
Copy or Download Result
Output refreshes on every keystroke, no button needed. Grab it with Copy, or use Download when you would rather have a file to attach to a ticket or commit.
Example
Encoding a simple JSON object to Base64:
JSON Input
Base64 Output
Frequently Asked Questions
Why encode JSON as Base64?
JSON often contains characters like {, ", and colons that can break URL parameters, HTTP headers, or config formats that only allow ASCII text. Base64 converts the JSON into a safe, compact string. It's widely used in JWTs, Authorization headers, and embedded config payloads.
Does this tool handle Unicode and emoji in JSON?
Yes. The encoder uses encodeURIComponent + unescape before calling btoa(), which correctly handles the full UTF-8 range including emoji, CJK characters, and other non-Latin scripts. See the MDN Unicode + Base64 guide for how this works.
Will the decoded JSON be formatted or minified?
When you decode Base64 back to JSON, the tool pretty-prints the result with 2-space indentation using JSON.stringify(parsed, null, 2). This makes it easy to read no matter how the original was formatted.
Can I paste a Data URI (data:application/json;base64,...) to decode?
Yes. If your Base64 string starts with data:, the tool automatically strips the Data URI prefix before decoding. Just paste the whole thing and it works.
Is my JSON data private?
It stays on your machine: encoding is the browser's own btoa() and decoding is atob(), so the page makes no request with your text. Bear in mind that Base64 only swaps the alphabet and locks nothing: whoever sees the string can turn it back into JSON with one line of code, so it is no place to hide a password or token.
What's the difference between Base64 and Base64url?
Standard Base64 (used here) uses + and / characters plus = padding. Base64url replaces those with - and _ (no padding) for use in URLs and JWTs. The RFC 4648 §5 defines the URL-safe variant.
Related Tools
The alphabet this page uses is section 4 of RFC 4648; a URL-safe string with - and _ has to be mapped back to + and / before atob() will accept it. The JSON being wrapped follows RFC 8259. MDN's Base64 glossary entry explains why btoa() chokes on raw UTF-8, and json.org has the syntax diagrams.