What this JSON formatter does
Paste JSON into the box and press Format. The page hands the text to the JSON.parse() function built into your browser; if the text parses, JSON.stringify() writes it back with two-space indentation and the status line reads "Formatted successfully". Minify runs the same parse and writes the value on one line with no whitespace. Copy puts whatever is in the box on your clipboard and Clear empties it. All of this is the page's own JavaScript: the text never leaves your browser, and the page loads no formatting library.
Validation is a side effect of parsing. When the text is not valid JSON, the status line turns red and shows the browser's own error message. Current Chrome and Edge name the character position and the line, for example Invalid JSON: Expected property name or '}' in JSON at position 1 (line 1 column 2). Firefox and Safari word their messages differently, so what you see depends on the browser you use. MDN keeps a guide to these parse errors.
What counts as valid JSON
The grammar is small and strict. RFC 8259 (the same grammar is published as ECMA-404 and summarised on json.org) defines a JSON text as a single value: an object in curly braces, an array in square brackets, a number, a string in double quotes, or one of the literals true, false and null. Object keys must be double-quoted strings, and whitespace is allowed only between tokens. Anything else, however common it is in JavaScript source, is an error here.
Reading the status line
The line under the box reports what the last button did:
Formatted successfully, or Minified successfully
What it means: the text parsed as JSON and has been rewritten. Formatted output uses two spaces per nesting level; minified output has no whitespace at all.
Next step: press Copy, or switch between Format and Minify as often as you like. The value does not change between the two.
Invalid JSON: ...
What it means: the parser stopped at the place named in the message. The position counts characters from 0; the line and column count from 1. Nothing in the box was changed.
Fix: go to that spot and look for the cases listed above: a trailing comma, a single quote, an unquoted key, a comment, or a bracket left open further up.
Ready, or Copied to clipboard
What it means: nothing has been validated yet. Ready is the starting state and the state after Clear; Copied to clipboard confirms the copy and says nothing about validity.
Next step: press Format or Minify to check the text. Pressing either with an empty box does nothing.
JSON value types
RFC 8259 allows exactly these six kinds of value. Everything in a document is one of them, nested as deeply as you need:
| Type |
Rules |
Example |
| String | Unicode text in double quotes; quotes, backslashes and control characters must be escaped | "Hello, World!" |
| Number | Decimal integer or fraction with an optional exponent; no leading zeros, no hex, no NaN or Infinity | 42, 3.14, -1.5e10 |
| Object | Zero or more name/value pairs in curly braces; names are strings and should be unique | {"name": "Alice", "age": 30} |
| Array | Ordered list of values in square brackets; the values may be of different types | [1, "two", true, null] |
| Boolean | The literal true or false, lowercase and unquoted | true, false |
| Null | The literal null, lowercase and unquoted; "null" in quotes is a string | null |
Frequently asked questions
Can JSON have comments?
No. The RFC 8259 grammar has no comment syntax, so this tool reports a comment as an error at the first slash. If you need annotated configuration files, JSONC (used by VS Code settings), JSON5 and YAML all allow comments, but strip them before pasting here.
Is the JSON I paste uploaded anywhere?
No. Parsing and formatting happen in your browser, and the page makes no request that carries your text. Like every page on this site it loads the Ahrefs Web Analytics script, which records the visit, not what you type.
How large a document can I format?
The specification sets no limit. The practical limit is your browser: the whole text and the whole parsed value have to fit in memory at once, so documents of tens of megabytes become slow and can freeze the tab. For files that size, use a streaming parser or the formatter in your code editor.
What is the difference between Format and Minify?
Both parse the text the same way. Format writes it back with two spaces per level (JSON.stringify(value, null, 2)) for reading and reviewing; Minify writes it with no whitespace for sending or storing. Switching between them never changes the data.
Related tools: if a JSON field carries Base64 data, the Base64 converter decodes it to text. The URL encoder prepares a JSON string for use as a query parameter, and the URL parser shows the decoded parameters of an API request you already have.