Why Encode JSON as Base64
Base64 can carry a JSON document inside a text-oriented field. It changes the byte representation but does not add privacy. Standard Base64 still needs proper URL encoding when placed in a query parameter.
How to Convert JSON to Base64
Paste valid JSON and use Encode. The tool checks JSON syntax before producing output. Copy the complete string and document whether the consumer expects standard Base64, Base64URL or another wrapper.
Minify JSON Before Encoding
This JSON mode normalizes the document to two-space indentation before encoding. For a compact payload, minify JSON first and encode it with the general Base64 Encode text tool, which preserves the supplied bytes. Never normalize a document before verifying a signature over its original bytes.
Base64, Base64URL and JWT Payloads
JWT payloads use Base64URL and have a defined token structure. A Base64-encoded JSON object alone is not a signed JWT. Use the JWT decoder to inspect token segments without confusing inspection with verification.
Encoding Is Not Encryption
Anyone holding the Base64 text can decode it. Do not treat an encoded password, API key or customer record as protected. Use transport security and an appropriate secret-management system for confidential data.
More examples and technical details
Why Encode JSON as Base64?
JSON is already text, so encoding it to Base64 is never about making it transportable in the way that images or PDFs need. It is about escaping. JSON is full of characters that carry meaning somewhere else in the stack: quotes, braces, colons, commas, ampersands, and newlines. Base64 flattens all of that into a single opaque token made only of letters, digits, and two punctuation marks, which sails through layers that would otherwise mangle it.
- Query parameters and URL fragments. Passing a small state object through a redirect without fighting nested percent-encoding.
- JWT payloads. The claims object is JSON, Base64URL encoded, and joined with dots.
- Environment variables and config values. A one line value that survives shell quoting, YAML parsing, and CI secret stores.
- Pagination cursors and opaque tokens. APIs encode a small JSON cursor so clients treat it as an atomic string rather than parsing it.
- Embedding structured data in HTML attributes or in headers where quoting rules are restrictive.
Worked Example: Encoding a JSON Object
Take a compact object with three fields. The encoder converts it to UTF-8 bytes and then applies the standard three bytes to four characters transformation.
Notice that every Base64 encoded JSON object begins with the characters eyJ. That is not a coincidence: the opening brace followed by a double quote always produces that prefix, which is a quick way to recognise an encoded JSON payload in a log file.
Minify Before You Encode
Base64 encodes bytes, and pretty printed JSON is full of bytes that carry no meaning. Every space of indentation and every newline is encoded faithfully and inflates the result. Minifying first, removing all whitespace between tokens, produces a shorter string that decodes to a semantically identical object.
Remember the underlying arithmetic: Base64 output is always about 33 percent larger than its input. Encoding JSON that is already safe to transmit costs you a third of the payload for no benefit, so reach for it only when the transport layer actually requires an opaque token. Key ordering also matters, because two objects that are logically equal but written with keys in a different order produce completely different Base64 strings.
Encoding Is Not Encryption
Encoding also gives no integrity guarantee on its own. Anyone can edit a Base64 encoded object and re-encode it. Only a signature, as used in the JWT signature segment, tells you the content has not been tampered with.
The Base64 Alphabet
Every 6 bit group produces a value between 0 and 63, and that value is looked up in the table below. RFC 4648 fixes this ordering: uppercase letters first, then lowercase, then digits, then the plus and slash characters. The padding character (=) is not part of the alphabet, it only marks the end of an incomplete group.
| Index | Char |
|---|---|
| 0 | A |
| 1 | B |
| 2 | C |
| 3 | D |
| 4 | E |
| 5 | F |
| 6 | G |
| 7 | H |
| 8 | I |
| 9 | J |
| 10 | K |
| 11 | L |
| 12 | M |
| 13 | N |
| 14 | O |
| 15 | P |
| Index | Char |
|---|---|
| 16 | Q |
| 17 | R |
| 18 | S |
| 19 | T |
| 20 | U |
| 21 | V |
| 22 | W |
| 23 | X |
| 24 | Y |
| 25 | Z |
| 26 | a |
| 27 | b |
| 28 | c |
| 29 | d |
| 30 | e |
| 31 | f |
| Index | Char |
|---|---|
| 32 | g |
| 33 | h |
| 34 | i |
| 35 | j |
| 36 | k |
| 37 | l |
| 38 | m |
| 39 | n |
| 40 | o |
| 41 | p |
| 42 | q |
| 43 | r |
| 44 | s |
| 45 | t |
| 46 | u |
| 47 | v |
| Index | Char |
|---|---|
| 48 | w |
| 49 | x |
| 50 | y |
| 51 | z |
| 52 | 0 |
| 53 | 1 |
| 54 | 2 |
| 55 | 3 |
| 56 | 4 |
| 57 | 5 |
| 58 | 6 |
| 59 | 7 |
| 60 | 8 |
| 61 | 9 |
| 62 | + |
| 63 | / |
Working on something related? Browse every free developer tool on the site, including a Base64 to JSON decoder, JSON minifier, JWT decoder, and URL encoder. Everything runs entirely in your browser, so nothing you paste is ever uploaded.
Standards and references
Frequently asked questions
How do I encode JSON to Base64?
Paste valid JSON into Encode mode and copy the Base64 result.
Should JSON be minified first?
Minification reduces bytes, but this JSON mode pretty prints before encoding. For compact output, use JSON Minifier followed by Base64 Encode in text mode.
Is Base64 safe for secrets?
No. Base64 is reversible without a key.
How is JSON used in JWTs?
JWT claims are JSON encoded as Base64URL inside a token structure, usually with a signature. Encoding JSON alone does not create one.
Is JSON uploaded?
No. Input is processed in this browser tab and is not uploaded by the tool. Copy and download are actions you control; ordinary page analytics do not receive tool input.