JSON Formatter

Paste JSON and get it back readable. This JSON formatter pretty-prints, validates and minifies as you type, points at the exact line and column of any syntax error, and gives you a collapsible tree, key sorting and CSV export.

How to use JSON Formatter

  1. Paste or type your JSON into the input box — or press “Load example” to see it working.
  2. Choose an indent of 2 spaces, 4 spaces, tabs or minified; optionally sort object keys alphabetically.
  3. If the JSON is invalid, read the error message: it names the problem and the exact line and column.
  4. Switch to the Tree tab to explore nested objects and arrays, or the CSV tab to flatten an array of objects.
  5. Copy the result or download it as a .json file.

About JSON Formatter

JSON is deliberately minimal, and that minimalism is exactly why a bad payload is so hard to read. A single-line response from an API is a wall of braces; a response with one misplaced comma is a wall of braces that silently breaks your parser. A JSON formatter solves both problems at once: it re-indents the structure so nesting becomes visible, and it validates against the specification so you find out immediately whether the problem is your code or the data.

Validity here is the browser’s own JSON.parse verdict, so what this page calls broken is exactly what your Node, Deno or browser runtime will call broken. Locating the break is a separate job, and one engines do badly: V8 omits the position for a trailing comma in an array, and Safari never reports one at all. So a second strict pass walks the document and reports the precise line, column and cause — “trailing comma before this closing bracket”, not “Unexpected token }” — with the offending line printed and a caret underneath it.

Beyond formatting, the tool covers the jobs that usually follow: sorting keys alphabetically to make two payloads diffable, escaping a document so it can be embedded inside another JSON string, and flattening an array of objects into CSV for a spreadsheet. The stats row keeps the numbers in view — original size, minified size, saving percentage, total keys, maximum nesting depth and array count — which is often the quickest way to spot that a response is far larger, or far deeper, than you expected.

Frequently asked questions

Is my JSON uploaded to a server?

No. Parsing, formatting and validation all happen in your browser tab using the JavaScript engine’s own JSON.parse. Nothing is transmitted, logged or stored, so it is safe to paste API responses that contain real data.

Why does my JSON say “invalid” when it looks fine?

The usual culprits are a trailing comma after the last item, single quotes instead of double quotes, unquoted keys, a stray comment, or NaN/undefined values. All four are legal in JavaScript but illegal in JSON. The error message shows the line and column so you can jump straight to it.

What is the difference between formatting and minifying?

Formatting adds newlines and indentation so a human can read the structure. Minifying strips every optional space and newline to make the payload as small as possible for transport. Both produce exactly the same data — the stats row shows how many bytes minifying saves.

Can it handle very large JSON files?

Yes, within your device’s memory. Files of a few megabytes format instantly on a laptop; beyond roughly 20 MB the browser tab, not the tool, becomes the limit. The tree view renders lazily so large arrays stay responsive.

How does the JSON to CSV conversion work?

It expects a flat array of objects — the shape most REST APIs return. Every key found across the array becomes a column, values are quoted only when they contain a comma, quote or newline, and nested objects are serialised back to JSON inside the cell.

Does it work offline?

Yes. Once the page has loaded there are no further network requests, so the formatter keeps working on a plane, on a locked-down network, or with the connection switched off.

Related tools

All developer tools · Browse all 56 free tools →