Skip to content

JSON Formatter

Paste messy JSON and get it back tidy and easy to read. It can also shrink it, sort it and fix common mistakes.

  • Free, no account
  • Nothing uploaded
  • 13 tools
Input
Output
working…in 338 B · 11 linesProcessed in this tab, no request made

Nothing you paste is uploaded. The server sends connect-src 'self', so your browser blocks this page from contacting any other host. Check it yourself

Format, minify, sort and repair JSON as you type, with errors located by line and column and a tree view. The text is processed in your browser tab.

How the JSON formatter works

The input is parsed with JSON.parse and written back with the indentation you choose, about a tenth of a second after you stop typing. Formatting changes whitespace only. Minify removes it, which is what you want before putting JSON in an environment variable or a single log line.

When the text is not valid, the output panel says where and why, and the position is underlined in the editor. For text that is almost JSON, switch to Repair:

{ 'order': "A-1042", items: [1, 2,], shipped: False }   // before
{ "order": "A-1042", "items": [1, 2], "shipped": false }  // after

Repair handles single quotes, unquoted keys, trailing commas, comments, Python literals and documents cut off before the closing bracket. It is a guess about your intent, so the page tells you whenever a repair changed the text.

Tree view and path lookup

The Tree view folds objects and arrays and shows how many members each has. The lookup above it takes a path such as $.items[0].sku, items[*].qty or $["odd key"] and lists every value it reaches. Keys, indexes (negative ones count from the end) and * are supported; filters and recursive descent are not.

Large files

From 200,000 characters up, parsing runs in a Web Worker so the editor stays responsive. Above 1,500,000 characters the result is produced when you press Run or Ctrl+Enter rather than on every keystroke.

Next steps with the result: generate TypeScript interfaces, export to CSV or convert to YAML. The "Send to" menu carries the output with you.

Questions

Short answers to what people ask most.

What is the difference between formatting and repairing?

Formatting only changes whitespace: the input must already be valid JSON and the data is untouched. Repair rewrites invalid text (single quotes, unquoted keys, trailing commas, comments, Python True/False/None, a missing closing bracket) into valid JSON, so it is a guess about what you meant. Compare the result before relying on it.

Does formatting change my numbers or key order?

Key order is kept unless you turn on "Sort keys". Numbers go through the JavaScript number type, so integers beyond 2^53 and decimals with more than about 17 significant digits lose precision, and 1.0 is written as 1. If you need those exact, keep them as strings.

Why does the error point to a line after the real mistake?

A parser reports the first place where the text stops making sense. A missing comma is noticed at the next token, and a missing closing quote may only be noticed at the end of the line. Look at the marked position and the token just before it.

Can I open a file instead of pasting?

Yes. Use "Open file" or drop a file on the input panel. The file is read by the browser with the File API and is not uploaded.