JSON Formatter
Paste JSON to format, validate or minify it instantly — with the exact line and column of any error. Nothing leaves your browser.
More options
Paste or type JSON above to validate, format or minify it — with the exact line and column of any error.
What "valid JSON" actually means
JSON looks forgiving but its grammar is strict, and most "my JSON won't parse" problems come from habits carried over from JavaScript. A formatter can only pretty-print text that is already valid, so the first job of this tool is to tell you exactly where the syntax breaks — the line and column of the first character the parser could not accept — and then, once the text is valid, to re-indent or compress it.
JSON allows just a handful of value types: objects in curly braces, arrays in square brackets, double-quoted strings, numbers, and the three literals true, false and null. Anything else — a comment, a single quote, a trailing comma, an unquoted key — is a syntax error, not a warning.
The rules people trip over
| Allowed | Not allowed |
|---|---|
Double quotes: "name" | Single quotes: 'name' |
{ "a": 1, "b": 2 } | Trailing comma: { "a": 1, } |
Quoted keys: "id" | Bare keys: id |
Numbers: 3.14, -2, 1e6 | Leading zero, +1, NaN |
| No comments | // or /* … */ comments |
Worked example 1 — finding the error
This input fails: { "name": "Ada", "skills": ["math", "code",] }
The parser stops at the ] because of the comma after "code" — a trailing comma. JSON has no trailing commas anywhere. Remove it and the object parses. The tool reports the column of the closing bracket, since that is the first token that is illegal given what came before.
Worked example 2 — Format versus Minify
Take {"id":7,"tags":["a","b"]} (25 characters). Format with 2-space indent expands it into a readable multi-line block for editing. Minify strips every optional space and newline to produce the shortest equivalent — useful for shrinking a payload before sending it over a network. Both represent the identical data; only the whitespace differs.
Worked example 3 — silent precision loss
Enter {"big": 9007199254740993} and format it: the value comes back as 9007199254740992. JSON numbers are parsed as 64-bit floating point, which can represent integers exactly only up to 253 = 9,007,199,254,740,992. Larger IDs must be stored as strings to survive a round trip.
Whitespace, key order and duplicates
- Indentation (2 spaces, 3 spaces, 4 spaces, or a tab) changes only readability, never meaning. Choose what your project's style guide expects.
- Sort keys reorders object members alphabetically, which makes two objects easy to compare in a diff. Object key order is not significant in JSON, so sorting is safe.
- Duplicate keys are technically permitted by the grammar but most parsers keep only the last one, so
{"a":1,"a":2}becomes{"a":2}. Avoid them.
Escaping special characters
Certain characters cannot appear literally inside a JSON string and must be escaped with a backslash: a double quote becomes \", a backslash becomes \\, and control characters use short codes such as \n for a newline and \t for a tab. Any Unicode character can also be written as \u followed by four hexadecimal digits, so \u00e9 encodes the letter é. A stray unescaped quote or a lone backslash is one of the most common reasons a string fails to parse, so when the reported error points inside a quoted value, look first for a character that should have been escaped.
Runs entirely in your browser
All parsing and formatting happen locally with the browser's own JSON engine — nothing you paste is uploaded. That means you can safely check configuration files or API responses that contain sensitive values. The one thing to remember is that a formatter validates syntax, not meaning: it confirms your JSON is well-formed, but it cannot know whether the field names and values are the ones your application expects.
Sources & further reading
Frequently asked questions
How does this JSON formatter show the exact error location?
When your text is not valid JSON, most online tools only say "invalid". This JSON validator goes further: it reads the byte position that the browser's own JSON parser reports for the first syntax error, converts it into a human line and column, and prints "Invalid JSON — line L, column C" alongside the parser's own message. Click Format or Minify and the offending line is selected in the input box so you can jump straight to it. That makes fixing a missing comma, an unclosed bracket or a stray quote far quicker than hunting through the whole document.
Format vs Minify vs Validate — what does each button do?
Format (beautify) re-indents your JSON with 2 spaces, 4 spaces or a tab so it is easy to read, optionally sorting object keys alphabetically. Minify strips every unnecessary space and newline to produce the smallest single-line JSON, ideal for API payloads and config values. Validate happens automatically as you type: the status badge turns green "Valid JSON" with key, depth and byte statistics, or red with the line and column of the first error. All three run instantly in your browser on the same parsed data.
Is my JSON sent to a server?
No. This JSON formatter runs 100% in your browser using the built-in JSON engine — nothing you paste is ever uploaded, logged or shared. That makes it safe for JSON that contains API keys, access tokens, secrets or personal data (PII), unlike ad-heavy sites that post your text to a backend. Your most recent input is optionally kept in this browser's local storage so it is still here when you return; untick "Save my JSON in this browser" to keep it for the session only, and Clear removes the stored copy.
Why do comments, single quotes or trailing commas fail?
Because this tool validates against the standard JSON specification (RFC 8259), not the relaxed JSON5 or JSONC dialects. Standard JSON requires double quotes around every key and string, forbids trailing commas after the last item, and does not allow comments (// or /* */) or single quotes. If your file uses those, the validator will point to the exact spot that breaks the rules — remove the comment, swap single quotes for double quotes, or delete the trailing comma and it will parse.
Why do very large integers lose precision, and how are duplicate keys handled?
JSON numbers are parsed as standard IEEE-754 doubles, so any integer above 2^53 − 1 (9,007,199,254,740,991) may be rounded — for example a 64-bit ID like 9223372036854775807 can come back slightly changed. Keep such values as strings if exact digits matter. When an object contains the same key twice, standard JSON keeps only the last occurrence, so duplicates are silently merged; the formatter follows that rule, which is another reason to validate machine-generated JSON before trusting it.