JSON Formatter and Validator
This tool formats and validates JSON (JavaScript Object Notation) entirely in your browser, so you can quickly turn messy or minified data into clean, readable text and catch syntax errors before they cause problems in your code, API calls or configuration files. Paste any raw or minified JSON into the input box, choose an indentation size of 2 spaces, 4 spaces or a tab, then click Format / Validate to pretty-print it with proper line breaks and indentation, or click Minify to strip all whitespace down to the smallest possible string. The status bar tells you straight away whether your JSON is valid, and if it is not, it reports the exact error message from the browser's parser, including the position of the first invalid character, so you can fix issues like trailing commas, single quotes or missing brackets. Below that, a statistics panel shows the validation status, the number of top-level keys or array items, the input size and the formatted output size in characters, giving you a quick sense of how your data is structured. A Copy Output button lets you grab the result straight to your clipboard. Because everything runs client-side using the browser's built-in JSON.parse() and JSON.stringify(), no data you paste is ever sent to a server, stored or logged, which makes this suitable for JSON containing sensitive information such as API keys or tokens.
1. Paste Your JSON
2. Formatted Output
How JSON Formatting Works
JSON (JavaScript Object Notation) is a lightweight text format for exchanging structured data. It is defined by ECMA-404 and RFC 8259. The format consists of two structures: objects (collections of key-value pairs enclosed in curly braces) and arrays (ordered lists enclosed in square brackets). Keys must be strings enclosed in double quotes, and values can be strings, numbers, booleans (true / false), null, nested objects, or arrays.
Formatting (also called pretty-printing or beautifying) adds newlines and indentation to make JSON easier to read. Minifying removes all whitespace to produce the smallest possible string, which is useful for reducing file sizes in APIs and config files. This tool uses the browser's native JSON.parse() to validate and then JSON.stringify() with an indent argument to produce formatted output.
Worked Example
Given the following minified JSON input (the default in this tool):
With 2-space indentation selected, the formatter produces:
The input has 4 top-level keys, an input size of 60 characters, and a formatted size of 95 characters.
Common JSON Errors
- Trailing comma:
{"a":1,}is invalid. Remove the comma after the last key-value pair or array element. - Single quotes:
{'name':'Alice'}is invalid. All keys and string values must use double quotes. - Unquoted keys:
{name:"Alice"}is invalid. Keys must always be quoted strings. - Undefined or NaN: JavaScript's
undefined,NaN, andInfinityare not valid JSON values. Usenullinstead, or convert numbers to strings. - Comments: JSON does not support comments. Remove any
//or/* */before parsing. - Unescaped control characters: Literal tab or newline characters inside a string value must be escaped as
\tor\n.
When to Use JSON vs Other Formats
JSON is the default data exchange format for REST APIs, web browser storage (localStorage, sessionStorage), and configuration files for Node.js projects and many modern tools. For configuration files that benefit from comments, YAML or TOML are popular alternatives. For binary efficiency over the wire, formats such as MessagePack or Protocol Buffers are used. For human-authored config where schema validation matters, JSON Schema can be layered on top of JSON.
Related Tools
- Essential Calculators: all computer, digital, and converter tools in one place.
- Base64 Encoder and Decoder: encode or decode Base64 strings used in JWTs and data URIs.
- IP Subnet Calculator (CIDR): calculate network addresses, host ranges, and subnet masks.
- Bandwidth Calculator: estimate data transfer times and throughput requirements.
Method: Validation and formatting use the browser's built-in JSON.parse() (ECMA-404 / RFC 8259) and JSON.stringify(indent). No server-side processing. Input size is measured in UTF-16 code units (same as JavaScript's String.length).
This tool processes all data locally in your browser. No input is transmitted or stored anywhere. Suitable for sensitive JSON content such as API keys, tokens, and configuration data.
Related calculators
- JSON Formatter & Validator NZ: beautify, Minify & Check JSON.
- JWT Decoder NZ: decode a JSON Web Token Online.
- JWT Expiry Checker NZ: is a JSON Web Token Expired?
- Lorem Ipsum Bytes Generator NZ: Placeholder Text to a Byte Size.