JSON formatter

Paste or drop a file

About this tool

Paste JSON, drop a file on it, or open one from disk. Validity is checked as you type, and an invalid document is reported with the line and column where the parser gave up rather than a bare error string.

Prettify indents it, minify strips it back to one line, and sorting keys puts objects into alphabetical order all the way down.

How it works

Parsing uses the browser's own JSON implementation, so what this page accepts is exactly what your code will accept — no lenient parser quietly forgiving a trailing comma that then breaks elsewhere. Error positions are read out of the browser's own message, and both the V8 and Firefox formats are handled, falling back to the raw message if neither matches.

Common questions

Does sorting keys reorder my arrays?

No. Array order carries meaning in JSON, so it is left alone. Only the keys inside objects are sorted, and that runs recursively through nested objects.

Is my JSON uploaded anywhere?

No. Everything happens in your browser. Nothing is sent, nothing is stored on a server, and there are no third-party scripts on the page. That matters more than it sounds — API responses routinely contain tokens and personal data.

What does the error tell me?

The line and column where parsing failed, alongside the browser's own message. That is usually enough to find a missing comma or an unescaped quote without hunting.

Is there a size limit?

No imposed limit. The practical ceiling is your browser's memory, since the whole document is parsed at once.

Why your JSON will not parse

Trailing comma

{"a": 1,} is valid JavaScript and invalid JSON. The spec allows no comma after the last member of an object or the last element of an array. This is the single most common cause, and the reported column will point at the closing brace rather than the comma itself.

Single quotes

JSON strings and keys must use double quotes. {'a': 1} is a JavaScript object literal, not JSON.

Unquoted keys

{a: 1} is valid JavaScript and invalid JSON. Every key must be a double-quoted string.

Comments

JSON has none. // and /* */ both fail. Some tools accept a variant called JSONC for configuration files; the specification does not, and neither does JSON.parse.

NaN, Infinity or undefined

None of the three are JSON values. They appear when an object has been serialised by something that did not check, and they will fail to parse on the way back in.

Unescaped control characters in a string

A literal newline or tab inside a quoted string is invalid — they must be written as \n and \t. This is common when text has been pasted into a JSON value by hand.

A byte order mark at the start of the file

An invisible marker some Windows editors write at the beginning of a UTF-8 file. The parser fails on character one with no visible cause. Save the file as UTF-8 without a BOM.

Large integers changing value

Not a parse error, and easy to miss. JSON numbers become IEEE-754 doubles, which are exact only up to 9,007,199,254,740,991. A 64-bit identifier beyond that will come back slightly wrong. Systems that must round-trip such values send them as strings.

Duplicate keys

Technically permitted by the specification, but the last value silently wins. If a value is not what you expect, check whether the key appears twice.

The same job at the command line

Worth knowing, particularly for files large enough that a browser is the wrong tool.

More tools

See the whole toolbox — thirty-seven free tools planned, all running in your browser.