JSON Formatter & Validator
Format, minify and validate JSON, with the exact line and column of a syntax error and large numbers kept as written.
- Top level
- Keys
- Maximum depth
- Size
Pin tools here. They are saved in this browser.
Pin a tool and its sticker lands here.
Format, minify and validate JSON, with the exact line and column of a syntax error and large numbers kept as written.
JSON is defined by RFC 8259 and ECMA-404. A document is one value: an object, an array, a string, a number, true, false or null. Strings and object keys are written in double quotes, and there is no syntax for comments.
Many broken documents contain something that a JavaScript object literal allows and JSON does not: a comma after the last item, single quotes, a key without quotes, or a comment. With Repair common mistakes turned on, this tool reads those, together with raw line breaks and tabs inside strings, a backslash before a single quote, and Python's True, False and None, tells you what it changed, and writes strict JSON.
Each browser words a JSON.parse error differently, and some do not say where it is. This tool reads the text with its own parser, so the message, the line and the column are the same everywhere. Go to the error selects the offending character in the input; when you paste a whole document, the tool does that by itself.
The position is where the parser could not continue, which can be slightly after the real mistake. A missing comma, for example, is reported at the first character of the next item.
The JSON grammar puts no limit on the size of a number, but JSON.parse in JavaScript turns every number into a 64-bit float, which can hold every integer exactly only up to 2 to the power of 53 (9,007,199,254,740,992). A larger identifier such as 12345678901234567890 comes back from JSON.parse as 12345678901234567000. This formatter copies the text of each number instead of converting it, so long integers, 1.0 and 1e5 leave exactly as they arrived, and it warns you when an integer would not survive a JavaScript parser.
RFC 8259 says the keys of an object should be unique, and that the behaviour of software receiving a duplicate is unpredictable. Many parsers keep only the last value without a warning. The formatter keeps every entry and tells you where the first duplicate is.
Sort keys orders the keys of every object, at every level, by UTF-16 code unit, which is the order of JavaScript's default sort: digits, then uppercase letters, then lowercase letters. Arrays keep their order. The size is counted in UTF-8 bytes.
No. The text is parsed and formatted by JavaScript in your browser tab, and the tool makes no network request with what you paste.
The grammar in RFC 8259 has no comment syntax and requires a value after every comma, so a standard parser rejects both. JSON5 is a separate format that allows them. Turn on the repair option to read such a file and get strict JSON back.
Formatting puts every item on its own line and indents it, which makes the structure readable. Minifying removes the whitespace between the items, which makes the document smaller to store and to send. The data is the same in both forms.
Not for a program that follows the specification, which describes an object as an unordered collection of name and value pairs. Sorting helps when you compare two documents line by line. Arrays are ordered, so their items are never moved.
It opens in its own window and keeps working offline.
To install it, tap the Share button, then “Add to Home Screen”.