Skip to content

JSON formatter

Format, validate and minify JSON.

Indent

Waiting for JSON.

Output

Your JSON is parsed by code in this browser tab; the page does not send or save it, and the site counts page views. Numbers and string escapes are kept exactly as you typed them.

How a JSON formatter works

A JSON formatter reads your text, checks that it follows the JSON grammar, and writes it out again with new spacing. Only the whitespace changes, which is why the same parse can pretty print, minify and validate.

The grammar, set by RFC 8259, is short. The browser's built-in JSON.parse gives the yes or no; because its error messages differ between browsers, this page also runs its own reader to explain what went wrong and give the exact line and column.

Unlike a plain JSON.stringify round trip, this tool keeps every number and string exactly as written, so 12345678901234567890 is not silently rounded.

What are the six JSON data types?

JSON data types
TypeExampleRules
Object {"id": 7} Keys are strings in double quotes, followed by a colon. Keys should be unique.
Array [1, "two", null] Ordered list. Items can be of mixed types.
String "caf\u00e9" Double quotes only. Quotes, backslashes and line breaks must be escaped.
Number -12.5e3 No leading zeros, no plus sign, no NaN or Infinity, no hex.
Boolean true Lowercase true or false.
Null null Lowercase. The only way to say "no value".

Source: RFC 8259, sections 2 to 7.

There is no date type, no comment syntax and no way to write undefined. Dates travel as strings, usually in ISO 8601 form, or as a Unix number that our Unix timestamp converter turns into a readable date, and a missing value is either left out or written as null.

What are the most common JSON errors, and how do you fix them?

What goes wrong, and the fix
ErrorLooks likeFix
Trailing comma {"a": 1,} Delete the last comma
Single quotes {'a': 'x'} Use double quotes
Unquoted key {a: 1} Write "a"
Missing comma {"a": 1 "b": 2} Add a comma between the pair
Comment {"a": 1 // note} Remove it; JSON has no comments
Leading zero [007] Write 7, or quote it as "007"
Bad literal [True, NaN, undefined] Use true, or null instead
Raw line break "line one line two" Write \n inside the string
Extra content {"a":1} {"b":2} Wrap the two values in an array

How do you read the error pointer?

The caret sits under the character where the reader gave up; where a piece is missing, it sits on the next thing the reader saw.

1234 { "name": "Dana", "age": 41, } ^ Line 3, column 12: Trailing comma before the closing brace
The tool's actual result for this four-line document. The comma after 41 is the thing to delete.
Why the line in your editor may differ

Counting starts at 1 and each tab counts as one column. A line that was minified onto a single row has only one line number, so use the column and the caret excerpt to find the spot.

When should you pretty print, use tabs or minify?

The same small object in each layout:

Layouts of: {"name":"Dana","tags":["a","b"],"active":true,"score":9.5,"address":null}
LayoutLinesSize
Minified 1 73 bytes
2 spaces 10 107 bytes
4 spaces 10 127 bytes
Tab 10 97 bytes

Source: Sizes in UTF-8 bytes. Deeper nesting makes the gap between pretty and minified larger.

Use 2 or 4 spaces for files people read and review, and minify when nobody will read the file by eye.

Sort keys reorders every object's keys alphabetically by character code, at all depths, and leaves arrays alone because their order carries meaning. Two objects that hold the same data then print identically, which makes them easy to compare in our text compare tool.

Common mistakes

  • Pasting a JavaScript object and expecting it to be JSON. Code like {name: 'Dana'} is valid JavaScript but has two JSON errors: an unquoted key and single quotes.
  • Large numbers in IDs. The standard warns that numbers beyond the range of a 64-bit float may not be read back exactly by other software. According to MDN, JavaScript's largest safe integer is 9,007,199,254,740,991. Send bigger IDs as strings. This page warns you when it sees one.
  • Duplicate keys. They are legal to write but unreliable to read: the standard says names should be unique, and JSON.parse keeps only the last. This page leaves both in place and lists them as a warning.
  • An invisible first character. A byte order mark at the start of a file makes browsers reject otherwise valid JSON. The error card names it so you can delete it.
  • Several JSON values in one file. Log files often hold one object per line (JSON Lines). That is not a single JSON document. Wrap the lines in [ ] and add commas to make it one. Binary or encoded fields are often wrapped in Base64; our Base64 encoder and decoder unwraps them.

Common questions

Is it safe to paste private JSON here?

The text is processed in your browser tab and the page sends it nowhere; the site does count page views. Keep secrets out of any pasted text anyway, and use our online notepad for scratch text you want to keep in this browser.

Can JSON have comments?

No. JSONC and JSON5 allow comments but are not JSON; strip them before validating.

Is a lone number or string valid JSON?

Yes. Since RFC 7159 (2014) and in RFC 8259, a JSON text can be any value, not only an object or array, so 42 and "hello" are valid.

How big a file can it handle?

Several megabytes format in well under a second on a current laptop; the colored view switches to plain text above about 250,000 characters.

Sources

Last reviewed November 9, 2026.