Skip to content

JSON formatter

Format, validate and minify JSON, with errors pinned to a line and column and explained in plain words.

Input

sample · 1 line · 131 chars

Output

valid · 14 lines · 185 chars

What it does

Paste JSON and get it back indented and readable, or squeezed onto one line. The tool checks it as you type: valid JSON is formatted straight away, and anything that is not valid gets a message with the line, the column and what is wrong.

  • 2 spaces, 4 spaces and Tab set the indentation.
  • Minify removes every space and line break that is not inside a string.
  • Sort keys puts each object’s properties in order by name. Capital letters sort before lower-case ones, as in most programming tools.

How to use it

  1. Paste your JSON into the input pane.
  2. Pick an output style. The result appears beside it and updates as you edit.
  3. If there is an error, the output pane says where it is. Fix that spot in the input; your text is never cleared or changed for you.
  4. Press Copy, or Download to save the result as a .json file.

Error messages are written to be acted on. Instead of “unexpected token”, you get something like Line 4, column 3: a comma is missing between two properties.

Questions

What are the most common reasons JSON is not valid?

A comma after the last item in a list or object, single quotes where double quotes are required, property names without quotes, a missing comma between two items, and comments. All of these are allowed in JavaScript and none of them in JSON. The error message says which one it is and where.

Will formatting change my data?

No. Only the spacing changes. Numbers are kept exactly as written, so a long ID such as 12345678901234567890 does not get rounded, and strings keep their escapes. Keys stay in their original order unless you turn on Sort keys.

What does Sort keys do?

It puts the properties of every object in order by name, at every depth. The order is the one most programming tools use: digits first, then capital letters, then lower-case letters, so Zebra comes before apple. Lists keep their order, because the order of a list means something. Sorting makes two JSON files much easier to compare.

How large a file can it handle?

Several megabytes without trouble. Large input is processed in the background so the page stays responsive while it works. The practical limit is how much text your browser will hold in a text box.

Is my JSON sent to a server?

No. It is parsed and formatted in your browser and never leaves your device. That makes it safe for API responses, configuration files and anything else with keys or personal data in it.