Using the JSON Formatter

Toolbar actions

  • Format: indent the document so it is readable.
  • Minify: strip every space and newline back out.
  • Validate: report the first syntax error with its line and column, plus a warning for any duplicate key.
  • Escape / Unescape: wrap the document as a string for embedding in another JSON document, or unwrap one that arrived that way.
  • Copy, Paste, Clear: move the document in and out of the clipboard, or empty the editor.
  • Upload, Export: open a .json file, or download what is in the editor.

Tabs

Tree View nests the document so branches can be collapsed; Grid View lays arrays of objects out as rows and columns. Both are editable and write back to the same document.

Format or minify JSON

Paste a document into the editor and press Format to indent it, or Minify to strip every space and newline back out. Formatting is a round trip through the parser rather than a text transform, so the output is always valid JSON — if the document cannot be parsed, nothing is rewritten and the error is reported instead. Both buttons work on the whole document; there is no selection mode.

Validate, and find where it actually breaks

Validate reports the first character that cannot appear where it does, as a line and column with the reason beside it. That position is worked out from the JSON grammar rather than read out of the browser’s error message, which matters because the common failures — a trailing comma, single quotes, NaN, undefined, Python’s True — are exactly the ones V8 reports without any position at all. A document that simply stops mid-value points at the end rather than at nothing.

Duplicate keys are reported, not silently dropped

An object with the same key twice is valid JSON, and every parser keeps only the last value — so by the time there is an object to inspect the duplicate is already gone. Validate scans the source text instead and warns you, naming the line. It is a warning rather than an error because the document really is valid; the gutter marker is there so a config where port appears twice does not quietly ship the wrong one.

{"port": 80, "port": 8080}valid — warning: duplicate key "port" on line 1

Read it as a tree or a grid

Tree view nests the document so you can collapse whole branches and see structure; grid view lays arrays of objects out as rows and columns, which is usually the faster way to scan a list of records. Both are editable and both write back to the same document, so a value changed in the grid is there when you switch to the code editor. Collapsed containers show their size — [500] or {4} — so you know what is inside before opening it.

A byte order mark is stripped for you

Files written by PowerShell, Excel and most .NET tools begin with an invisible byte order mark, and it makes JSON.parse fail on character one with a message naming a character you cannot see or select. It is removed wherever text enters the editor — paste, upload or the sample — so the document you are editing is the document you think you are editing, and every reported position lines up with what you can count.

Two number limits worth knowing

Formatting round-trips through the parser, so a value too large for a double comes back changed: 1e400 becomes null, and an integer past 2^53 is rounded to the nearest representable one. This is not a quirk of this tool — jsonlint does exactly the same, for the same reason — but a formatter’s output gets pasted back somewhere, so it is worth knowing before you format a file full of large IDs.

Frequently asked questions

Is my JSON uploaded to a server?

No. The page is a static export with no backend, and every operation — formatting, validation, the tree and grid views — runs in your browser. Nothing you paste leaves the tab, which is why it still works with the network disconnected.

Why does Validate say my JSON is valid when a key appears twice?

Because it is valid. The JSON specification allows repeated keys and leaves the result to the parser, and every common parser keeps the last one. The duplicate is reported as a warning with its line number rather than an error, so you can decide whether it was intentional.

Why did my large number change when I formatted the document?

Formatting parses the document and writes it back out, and JavaScript numbers are doubles. 1e400 exceeds what a double can hold and becomes null; an integer above 2^53 is rounded. Only a parser that preserved the original text of each number could avoid this, and the established online formatters behave the same way.

Can I edit the JSON in the tree or grid view?

Yes. Both views are editable and commit to the same underlying document, so a change made in the grid appears in the tree and in the code editor. Removing a key or an array element updates the document rather than leaving a hole.

What is the difference between Escape and Unescape?

Escape turns the document into a string you can safely embed inside another JSON document — quotes become \" and newlines become \n. Unescape reverses it, which is the quicker way to read a JSON payload that arrived wrapped inside a log line or another field.

Dedicated tools

  • JSON Compare — diff two JSON documents with key order and indentation ignored.