How to use the JSON formatter
- Paste JSON into the box, drop a .json file on it, or use Open file. The file is read by this page and never uploaded.
- Pick an output. Format lays the JSON out with 2 spaces, 4 spaces or tabs (JSON pretty print). Minify removes every optional space and line break. Validate only checks the JSON and skips the output, which is quicker for very large files.
- Read the result. The panel says Valid JSON or Not valid JSON. For an error you get the line, the column, a plain-words reason and the line itself with the problem marked. Show in the box selects that spot in your text.
- Copy or download the output as a .json file.
Tick Sort keys A to Z to put every object's keys in order, at every level. Everything runs in this page: the JSON is never sent anywhere, and once the page has loaded it keeps working with no connection.
JSON pretty print and minify: a worked example
This minified JSON is 35 bytes on one line:
{"id":7,"tags":["a","b"],"ok":true}
Formatted with 2 spaces, the same data is 61 bytes and easy to read. Each value in an object or array gets its own line, and each level is indented once more:
{
"id": 7,
"tags": [
"a",
"b"
],
"ok": true
}
| Output | Size of this example | Good for |
|---|---|---|
| Minified | 35 bytes | Sending over a network, storing |
| Tab indent | 53 bytes | Teams that indent with tabs |
| 2 spaces | 61 bytes | Reading, code reviews, config files |
| 4 spaces | 77 bytes | Reading deeply nested data |
The data is identical in all four: JSON ignores whitespace between its parts. The formatter only changes spaces and line breaks (and the key order, if you sort). Numbers and strings are copied exactly as written, so 1.50 stays 1.50 and \u00e9 stays as that escape.
Validate JSON: reading a syntax error
This JSON is missing a comma after 30:
{
"name": "Ann",
"age": 30
"city": "Denver"
}
The validator reports line 4, column 3: "Missing comma: expected , or } before a double quote (")." Line 4 is where the parser noticed, which is often just after the real mistake, so look at the end of the line before too. Columns count characters from 1, with a tab or an emoji as one character.
Messages from programs vary, because each JavaScript engine words its own errors. This page uses its own checker, so a JSON syntax error is described the same way in every browser. The most common ones:
| You wrote | Why it is not JSON | Write instead |
|---|---|---|
[1, 2, 3,] | Trailing comma before ] or } | [1, 2, 3] |
{name: "Ann"} | Property names need double quotes | {"name": "Ann"} |
{'name': 'Ann'} | Single quotes are not allowed | {"name": "Ann"} |
// note | JSON has no comments | Remove it, or use a "note" key |
NaN, Infinity, undefined | Not JSON values | null, or a string |
True, None | Literal names are lowercase | true, null |
007, .5, 0x1F | Leading zero, no digit before the point, hexadecimal | 7, 0.5, 31 |
| A real line break inside "..." | Control characters must be escaped | \n |
For the trailing comma in {"name": "Ann", "age": 30,}, the error points at the comma itself: line 1, column 26.
What counts as valid JSON
JSON is defined twice, in RFC 8259 from the IETF and ECMA-404 from Ecma International. RFC 8259 says "The intent is that the grammar is the same between the two documents". ECMA-404 describes JSON as "a lightweight, text-based, language-independent syntax for defining data interchange formats". This page checks the strict grammar:
- A JSON text is one value (an object, array, string, number, true, false or null), with optional whitespace around it. Top-level strings and numbers are valid too.
- Whitespace is only space, tab, line feed and carriage return. A no-break space copied from a web page is an error.
- Strings use double quotes. RFC 8259 lists what must be escaped: "quotation mark, reverse solidus, and the control characters (U+0000 through U+001F)".
- Numbers: "Leading zeros are not allowed", and "Numeric values that cannot be represented in the grammar below (such as Infinity and NaN) are not permitted."
- "The literal names MUST be lowercase."
- The grammar has no comments and no trailing commas.
Two things are valid but risky, so the page warns about them. Duplicate keys: RFC 8259 says "The names within an object SHOULD be unique", and when they are not, "the behavior of software that receives such an object is unpredictable". Very large integers: RFC 8259 notes that integers in the range "[-(2**53)+1, (2**53)-1] are interoperable". A number such as 12345678901234567890 is kept exactly here, but JavaScript rounds it, so send IDs that long as strings.
A byte order mark at the start of a file is skipped, since RFC 8259 says parsers "MAY ignore the presence of a byte order mark rather than treating it as an error", and it is left out of the output.
Fix common mistakes, and what it will not fix
JSON copied from JavaScript, a config file or Python often breaks the rules in the same few ways. Fix common mistakes changes only these, outside strings: it removes comments and trailing commas, turns single-quoted strings into double-quoted ones, puts double quotes around bare property names, turns \' into ', and turns Python's True, False and None into true, false and null. It tells you what it changed, and Undo fix puts your text back.
{
// order details
id: 1042,
'status': 'paid',
items: ['pen', 'pad',],
}
becomes valid JSON, which minifies to {"id":1042,"status":"paid","items":["pen","pad"]}. The fix reports 1 comment and 2 trailing commas removed, 4 single-quoted strings changed and 2 bare names quoted.
It does not guess at anything else. NaN, Infinity and undefined stay, because JSON has nothing that means the same: choose null or a string yourself. Missing commas, unclosed brackets and curly quotes are also left for you, because the right fix depends on what you meant.
Large files and privacy
The checker reads the text in a single pass and never runs it as code. The result shows how long the check took on your device. Putting several megabytes of output on screen can take a moment longer, so for a very large file choose Validate only or Download .json. Files up to 50 MB can be opened.
Your entries are not saved or sent: the JSON is checked by code in this page and is never uploaded. Even so, think twice before pasting secrets such as live API keys into any website.
Questions and answers
Is this JSON formatter online free, and is my JSON sent anywhere?
It is free, with no sign-up. The JSON is checked and formatted by code in this page; your entries are not saved or sent.
What is the difference between a JSON formatter and a JSON validator?
A validator checks that the text follows the JSON rules and points to the first error. A formatter (or JSON beautifier) lays valid JSON out with indents and line breaks. This page does both, and can also minify.
Why does JSON not allow comments or trailing commas?
The JSON grammar in RFC 8259 and ECMA-404 simply has no place for them, and strict parsers reject them. Use Fix common mistakes to strip them, or keep notes in a key such as "note".
Why does my program reject JSON that this page says is valid?
Usually duplicate keys, integers larger than 9,007,199,254,740,991, a byte order mark, or a program that wants an object at the top level. The page warns about the first three.
Does sorting keys change my data?
No. JSON objects are unordered name and value pairs, so sorting only changes the order they are written in. Arrays are never reordered, because their order matters.
Can it check JSON Lines (one JSON value per line)?
Not as a whole: a JSON text holds one value, so the second line is reported as extra text. Check one line at a time, or wrap the values in [ ] with commas between them.
Sources
Checked on 9 October 2026. If a rule has changed, please tell us.