Tools
EN

JSON Formatter

Paste JSON, format it, validate it. The tool pinpoints errors by line and column and can repair them for you.

Input

Drop the file here
Your data never leaves your browser

The result appears here.

What is a JSON formatter?

A JSON formatter turns one long, squashed line of JSON into neatly indented text that people can read. It also checks whether the JSON is valid and shows the exact spot where it breaks.

What is JSON?

JSON stands for JavaScript Object Notation. It is a text format programs use to exchange data: an app asks a server, the server answers in JSON. The format is defined in RFC 8259 and ECMA-404.

JSON has exactly six kinds of values: strings in double quotes, numbers, true and false, null, arrays in square brackets and objects in curly braces. An object is a set of key and value pairs. That is all there is, which is exactly why JSON is everywhere.

How it works in 3 steps

  1. Paste your JSON into the left field or drop a file onto it.
  2. Pick the indentation: 2 spaces, 4 spaces or tab. The result shows up on the right straight away.
  3. Copy it, save it as .json or share it as a link. If the tool reports errors, "Auto-fix" repairs the usual ones in one click.

The most common JSON errors and how to fix them

Nearly every broken JSON document fails on one of these six points. Auto-fix handles all six.

Missing comma

Wrong
{
  "name": "Anna"
  "age": 31
}
Right
{
  "name": "Anna",
  "age": 31
}

Two entries need a comma between them. It often goes missing when single lines are copied around.

Trailing comma

Wrong
{ "tags": ["a", "b",], }
Right
{ "tags": ["a", "b"] }

No comma is allowed after the last entry. JavaScript forgives it, JSON does not.

Single quotes

Wrong
{ 'name': 'Anna' }
Right
{ "name": "Anna" }

Keys and strings need double quotes. Python prints dictionaries with single quotes, and that is not JSON.

Unquoted keys

Wrong
{ name: "Anna" }
Right
{ "name": "Anna" }

JavaScript lets you drop the quotes around a key. JSON never does.

Comments

Wrong
{
  // user id
  "id": 7
}
Right
{
  "id": 7
}

JSON has no comments. If you need them, use JSONC or YAML, or add a field such as "_note".

NaN, undefined, Infinity

Wrong
{ "ratio": NaN, "next": undefined }
Right
{ "ratio": null, "next": null }

These values only exist in JavaScript. In JSON, null takes their place.

JSON vs. YAML vs. XML

All three describe nested data. JSON is the default for APIs, YAML for configuration files that people maintain by hand, and XML wherever documents, namespaces or legacy systems are involved.

JSONYAMLXML
Typical useAPIs, data exchangeConfiguration (Docker, Kubernetes, CI)Documents, feeds, legacy interfaces
Commentsnoyesyes
Readabilitygood once formattedvery good, but indentation mattersverbose because of tags
Data typessix fixed typeslike JSON plus dates and moreeverything is text, types only via a schema
Typical mistakescommas and quotesindentation, "no" turning into falseforgotten closing tags

Frequently asked questions

Is my data uploaded anywhere?

No. Formatting, validating and converting all run in your browser. There is no upload and no server log of your content. You can verify it yourself: load the page, go offline, keep working.

How large can the file be?

Up to 50 MB for free. A web worker does the work in the background, so the page stays responsive. Only the visible lines are rendered, which is why even millions of lines scroll smoothly.

What does auto-fix repair?

Missing and trailing commas, single and curly quotes, unquoted keys, comments, NaN and undefined, Python spellings such as True and None, missing closing brackets, Markdown code fences and JSONP wrappers. Every change is listed before you apply it.

How do I format JSON in VS Code?

Open the file and press Shift + Alt + F (Mac: Shift + Option + F). VS Code refuses when the JSON is invalid, though. In that case paste it here to see what is wrong.

How do I format JSON on the command line?

With jq: jq . file.json. Without jq, python3 -m json.tool file.json works too. Both stop at the first error and repair nothing.

What is the difference between formatting and minifying?

Formatting adds line breaks and indentation so people can read the JSON. Minifying removes them again so the file gets smaller. The content is identical either way.

Why does my program throw an error although the JSON looks fine?

Invisible characters are a frequent cause: a BOM at the start of the file, a non-breaking space, or curly quotes pasted from Word or a chat window. The tool reports and removes them.

Can I share the result with someone?

Yes, with "Share link". The content is compressed and written into the part of the link after the #. Browsers never send that part to a server. It works up to roughly 64 KB.

How do I copy the path to a value?

Click the row in the tree view and choose "Copy path". You get a path such as data.items[3].name that you can drop straight into JavaScript or jq.

Related JSON tools