How to use the base64 to json converter
- Paste your base64-encoded string into the input area.
- Set the desired number of indent spaces for the output formatting.
- The tool automatically decodes the base64 to json and displays the result.
- Copy the formatted JSON output for use in your application or API.
How base64 to json decoding works
Converting base64 to json involves two distinct steps. First, the base64 string is decoded back into raw bytes, which are then interpreted as a UTF-8 text string. Second, that text string is parsed as JSON.
Base64 encoding maps every three bytes of binary data into four ASCII characters using a 64-character alphabet (A through Z, a through z, 0 through 9, plus + and /). Padding with = signs ensures the final block is exactly four characters long. For example, the JSON text {"a":1} is seven bytes. Encoded, it becomes eyJhIjoxfQ==.
The decoding reverses this mapping. Each group of four base64 characters is converted back into three original bytes. Once the full byte sequence is recovered, it is read as a UTF-8 string. If that string conforms to the JSON specification (RFC 8259), it can be parsed and reformatted with indentation.
Standard versus URL-safe base64
There are two common variants of base64 encoding. Standard base64 uses + and / as its 62nd and 63rd characters. However, these characters have special meanings in URLs and file paths, which causes problems when transmitting encoded data over HTTP.
URL-safe base64 replaces + with - and / with _. It also frequently omits the trailing = padding characters. When you convert base64 to json, the decoder must handle both variants. This tool automatically normalizes URL-safe characters back to standard base64 before decoding, ensuring reliable results regardless of how the string was originally encoded.
Common sources of base64-encoded JSON
You will frequently encounter base64-encoded JSON in several technical contexts:
- JSON Web Tokens (JWT): The payload of a JWT is a base64url-encoded JSON object. Tools like the JWT decoder perform this exact extraction alongside signature verification.
- Kubernetes Secrets: Data stored in Kubernetes Secret manifests is base64-encoded. The values are often JSON strings representing configuration files.
- API Responses: Some REST APIs encode complex nested payloads or binary attachments containing JSON metadata in base64 to avoid character escaping issues during transport.
- Browser Storage: Occasionally, web applications store JSON state in localStorage or cookies after base64 encoding to prevent injection or parsing errors.
If you are working with other configuration formats, you might also need tools to convert TOML to JSON, INI to JSON, or environment variables to JSON.
Handling invalid input
A base64 to json conversion can fail at either of the two stages. Understanding where the failure occurs helps you fix the source data.
| Error type | Cause | Solution |
|---|---|---|
| Invalid base64 | String contains characters outside the base64 alphabet, or incorrect padding length. | Remove whitespace, ensure correct padding, check for truncated strings. |
| Invalid UTF-8 | Decoded bytes do not form a valid UTF-8 sequence. | The original data may be binary, not text. Base64 to json only works for text. |
| Invalid JSON | Decoded text is not valid JSON (e.g., missing quotes, trailing commas). | Use a JSON formatter on the decoded text to locate syntax errors. |
This tool reports exactly which stage failed, so you know whether to fix the encoding or the underlying JSON structure.
Formatting the decoded JSON
Once the base64 string is successfully decoded and parsed as JSON, the output can be formatted for readability. The indent parameter controls how many spaces are used for each nesting level. An indent of 2 is standard for most configuration files and API responses, while an indent of 4 is preferred in some enterprise environments.
Setting the indent to 0 produces minified JSON with no extra whitespace. This is useful when you need to re-encode the JSON back into base64 for transmission, as smaller payloads reduce bandwidth usage. You can always paste the minified output into a JSON viewer later if you need to inspect it again.
Worked examples
| Example | Input | Result |
|---|---|---|
| Simple object | Base64 string: eyJuYW1lIjoiSm9obiIsImFnZSI6MzB9; Indent spaces: 2 | { / "name": "John", / "age": 30 / } |
| Array of items | Base64 string: WzEsMiwzXQ==; Indent spaces: 2 | [ / 1, / 2, / 3 / ] |
| Nested object | Base64 string: eyJ1c2VyIjp7ImlkIjoxLCJyb2xlcyI6WyJhZG1pbiIsInVzZXIiXX19; Indent spaces: 2 | { / "user": { / "id": 1, / "roles": [ / "admin", / "user" / ] / } / } |
| URL-safe base64 | Base64 string: eyJ1cmwiOiJodHRwczovL3guY29tL3E_YT0xJmI9MiJ9; Indent spaces: 2 | { / "url": "https://x.com/q?a=1&b=2" / } |
FAQ
What is base64 to json conversion?
It is the process of taking a string encoded in base64, decoding it back into plain text, and then parsing that text as a JSON document. This is common when APIs or storage systems encode JSON payloads to safely transmit them as ASCII text.
Does this tool support URL-safe base64?
Yes. The converter automatically detects URL-safe base64 by replacing hyphens with plus signs and underscores with slashes before decoding. It also handles missing padding characters.
Why does my base64 string fail to decode as JSON?
The string might contain invalid base64 characters, or the decoded text might not be valid JSON. Common JSON errors include unquoted keys, trailing commas, or single quotes instead of double quotes.
Is my data sent to a server?
No. The entire base64 to json decoding process happens locally in your browser using JavaScript. Your encoded data never leaves your device.
Can I decode a base64 string that is not JSON?
This specific tool expects the decoded text to be valid JSON. If your base64 string decodes to plain text or binary data, you should use a general base64 decoder or a binary to text tool instead.
How do I format the output JSON?
Use the indent spaces field to control formatting. Enter 2 or 4 for pretty-printed JSON, or 0 for compact, minified output without extra whitespace.