JSON Formatter & Validator
Paste JSON to pretty-print it, minify it, or check it for errors.
How to use
- Paste your JSON into the Your JSON box.
- Press Format to pretty-print it with two-space indentation, or Minify to strip all optional whitespace onto one line.
- Press Validate to check the text without changing it. A valid document is reported with its type and its length in characters.
- If the text is not valid, the result panel gives the line and column where parsing stopped, plus the parser's description of the problem.
- Press Copy result to copy what is in the result panel, or Clear to reset.
Worked example
Paste this document. A comma is missing after the tags array:
{
"name": "Ada",
"tags": ["a", "b"]
"age": 36
}
Format reports Invalid JSON at line 4, column 3, with a description such as "Expected ',' or '}' after property value". That points at the "age" key on line 4, not at the end of line 3 where the comma belongs. The parser cannot know a comma was forgotten until it meets the next token. The exact wording comes from your browser, so Chrome, Firefox and Safari word it differently, but the position is the same.
Add the comma and press Format again to get:
{
"name": "Ada",
"tags": [
"a",
"b"
],
"age": 36
}
Minify turns the same document into {"name":"Ada","tags":["a","b"],"age":36}.
How it works
The page hands your text to the browser's built-in JSON parser and prints the result back with JSON.stringify. The grammar is defined in RFC 8259 and in ECMA-404. A document is one value: an object, an array, a string, a number, true, false or null. Strings must use double quotes, and object keys are strings. There are no comments and no trailing commas. The MDN JSON reference covers the JavaScript methods used here.
Because Format and Minify parse and then rebuild the text, the output reflects what a parser sees, not what you typed. Whitespace is normalised, escape sequences are rewritten in their shortest form, and the order of keys is kept.
Common mistakes and edge cases
- Trailing commas.
{"a":1,}is invalid. JavaScript object literals allow the comma, JSON does not. - Single quotes.
{'a':1}is invalid. JSON needs double quotes around strings and keys. - Comments. JSON has none. Config formats that allow them, such as JSONC, need a different parser.
- Big numbers lose digits. The browser reads numbers as 64-bit floating point. The value
12345678901234567890is printed back as12345678901234567000, and1.0becomes1. If exact digits matter, as with large IDs, keep them as strings. - Duplicate keys. RFC 8259 says names should be unique. In practice the last one wins, so
{"a":1,"a":2}formats as{"a":2}and the first value is silently dropped. - Several documents in one box. Newline-delimited JSON (one object per line) is not a single valid document. Validate one line at a time.
Frequently asked questions
Why does the error point at the wrong place?
The parser reports where it noticed the problem, which can be after the mistake. Look at the end of the previous line or value as well.
Is JSON the same as a JavaScript object?
No. JSON is a text format that looks like object literal syntax but is stricter. Functions, undefined, comments and single quotes are not allowed.
Does Format change my data?
Not the values, with the exception of numbers that cannot be held exactly as 64-bit floats, as described above.
What is the largest JSON I can paste?
There is no fixed limit, but very large documents make the page slow because everything happens in one tab.
Is my JSON sent anywhere?
No. Parsing and formatting happen in your browser and nothing is stored.
Related tools
- CSV and JSON Converter to move between spreadsheets and JSON.
- Diff Checker to compare two formatted JSON documents line by line.
- JWT Decoder to read the JSON inside a token.
- Base64 & URL Encoder/Decoder for JSON carried in a URL or header.