1. Home
  2. Blog
  3. How to Format and Validate JSON (and Fix the Most Common Errors)
JSON Toolkit

How to Format and Validate JSON (and Fix the Most Common Errors)

Published 28 October 2026 · 7 min read

JSON is everywhere: API responses, configuration files, app settings, exported data. Computers read it easily, but people don’t, especially when it arrives squeezed onto a single line. And JSON is strict: one missing comma or one wrong quote, and the program reading it gives up.

This guide shows how to format JSON so it’s readable, how to validate it, and how to fix the six mistakes behind most broken JSON, using the free JSON Formatter & Validator.

Formatting and validating: what’s the difference?

Formatting (also called beautifying or pretty-printing) only changes the layout: it adds line breaks and indentation so the structure is easy to follow. Keys, values and their order stay exactly the same. Compare:

{"user":{"id":1024,"name":"Ada Lovelace","roles":["admin","editor"],"active":true}}
{
  "user": {
    "id": 1024,
    "name": "Ada Lovelace",
    "roles": ["admin", "editor"],
    "active": true
  }
}

Validating checks that the text follows the rules of JSON, so that any program can read it. A good validator doesn’t just say “invalid”: it tells you where the problem is and what’s wrong.

How to format and validate JSON, step by step

  1. Open the JSON Formatter.
  2. Add your JSON. Paste it into JSON input, click Open file, or drop a .json file onto the box. Click Sample to try it with an example.
  3. Watch the live check. While you type, the box shows ✓ This is valid JSON or an error with its line and column. Go to error jumps straight to the spot.
  4. Choose the layout. Under Indentation, pick 2 spaces, 4 spaces or Tab. Tick Sort keys A to Z if you want the properties in alphabetical order.
  5. Click Format & validate. The formatted JSON appears on the right, with a short summary of its structure. Use Copy or Download to take it with you.

The 6 most common JSON errors and how to fix them

1. A comma after the last item

Many programming languages allow it, JSON doesn’t. Remove the comma before a closing } or ].

// wrong
{ "name": "Ada", "age": 36, }

// right
{ "name": "Ada", "age": 36 }

2. Single quotes

Texts and property names must use double quotes. Single quotes are a JavaScript habit, not JSON.

// wrong
{ 'name': 'Ada' }

// right
{ "name": "Ada" }

3. Property names without quotes

In JavaScript you can write name: "Ada"; in JSON every property name needs double quotes.

// wrong
{ name: "Ada" }

// right
{ "name": "Ada" }

4. Comments

JSON has no comments at all. Remove them, or keep notes in a separate field such as "_note". (Some tools accept variants like JSONC or JSON5, but standard JSON readers don’t.)

// wrong
{
  "port": 8080 // the web server
}

// right
{
  "port": 8080
}

5. A missing comma between items

Every property and every array item must be separated by a comma. This often happens when you paste two parts together.

// wrong
{ "name": "Ada" "age": 36 }

// right
{ "name": "Ada", "age": 36 }

6. Values JSON doesn’t know

JSON only has strings, numbers, true, false, null, objects and arrays. NaN, undefined and capitalised True are not allowed.

// wrong
{ "score": NaN, "ok": True, "x": undefined }

// right
{ "score": null, "ok": true, "x": null }

The validator recognises each of these mistakes and explains it in plain words, with the line and column where it happens.

Two things many formatters get wrong

  • Large numbers. Many online formatters run JSON through JavaScript, which quietly rounds big IDs: 9007199254740993 becomes 9007199254740992, and 1.10 becomes 1.1. Our formatter keeps every number exactly as you wrote it.
  • Duplicate keys. If the same property appears twice in one object, most programs silently keep only the last value. The formatter warns you, so you can decide which one is right.

More you can do with JSON

Is my JSON uploaded?

No. Formatting and validating happen in your browser, so your data never leaves your device. That matters, because JSON often contains API keys, customer data or internal settings.

Frequently asked questions

Should I use 2 or 4 spaces?

Both are fine; it’s a matter of taste. 2 spaces is the most common choice for JSON and keeps deeply nested data narrower.

Does sorting the keys change my data?

No. The order of properties in an object has no meaning in JSON, so sorted JSON holds exactly the same data. It just makes long objects easier to scan and compare.

Can JSON contain comments?

No. Standard JSON doesn’t allow them. Remove comments before using the file, or store notes in a regular field.