JSON Formatter

Format and validate JSON, see exactly where it breaks, and fix common errors.

Runs in your browser. Nothing you enter is uploaded.

Output

How to use JSON Formatter

  1. Paste your JSON, an API response or a config file. The result appears as you type.
  2. Pick Format for readable JSON or Minify for the smallest size.
  3. Broken JSON is repaired, and every fix is listed under the result. Turn off Fix common errors to only validate.
  4. If it can't be fixed, you get the line and column of the problem. Press Show in the input to jump there.
  5. Copy the result or download it as a .json file.

Examples

A config file with comments and loose syntax

Settings
  • Output: Format
Input
{
  // database settings
  host: 'localhost',
  port: 5432,
  "ssl": {"enabled": true, "verify": false,},
}
Result
{
  "host": "localhost",
  "port": 5432,
  "ssl": {
    "enabled": true,
    "verify": false
  }
}

The comment goes, the keys and the single-quoted text get double quotes, and both trailing commas are removed. The list under the result names each fix.

A Python dictionary

Settings
  • Output: Format
Input
{'name': 'Marko', 'active': True, 'manager': None, 'scores': [9.5, 8, NaN]}
Result
{
  "name": "Marko",
  "active": true,
  "manager": null,
  "scores": [
    9.5,
    8,
    null
  ]
}

True and None become true and null. NaN has no JSON form, so it becomes null too.

Minify for an API request

Settings
  • Output: Minify
Input
{
  "query": "keyboard",
  "page": 1,
  "filters": {
    "inStock": true,
    "maxPrice": 120
  }
}
Result
{"query":"keyboard","page":1,"filters":{"inStock":true,"maxPrice":120}}

Spaces and line breaks between values go. Text inside strings stays exactly as it was.

How it works

The formatter reads your JSON character by character with its own parser, so it can say exactly where the JSON breaks and why, the same way in every browser. Then it writes the data back with the spacing you picked. Numbers and text stay exactly as you typed them: 1.10 stays 1.10, and big IDs like 12345678901234567890 aren’t rounded, which happens when JSON goes through JavaScript’s own parser.

With Fix common errors on, the tool repairs what it can safely guess and lists every change under the result, with line numbers. With it off, the tool only validates: you get the first error, its line and column, and the lines around it with the spot marked.

Errors it fixes

Problem Example and fix
Trailing comma [1, 2,] becomes [1, 2]
Single quotes {'a': 'b'} becomes {"a": "b"}
Keys without quotes {name: "Ana"} becomes {"name": "Ana"}
Comments // note or /* note */: removed
Python values True, False, None become true, false, null
Not-a-number values NaN, Infinity, undefined become null
Missing comma [1 2] becomes [1, 2]
Missing closing brackets {"a": [1, 2 becomes {"a": [1, 2]}
Invalid numbers 007, .5, +1, 0xFF become 7, 0.5, 1, 255
Lone backslashes "C:\Users" becomes "C:\\Users"
Line breaks inside text a real line break inside a string becomes \n
Curly quotes “a” becomes "a"
Wrappers Markdown code fences, callback(...), const data = ...: only the JSON inside is kept
Escaped JSON {\"a\": 1} becomes {"a": 1}
JSON Lines one object per line becomes a list of objects
MongoDB types NumberLong(42), ISODate("…") become 42, "…"

Repairs are guesses, so read the list under the result. If a value looks wrong, fix the input by hand and turn off Fix common errors to confirm it’s valid.

What it can’t fix

  • An HTML page instead of JSON. If the text starts with <, a server sent an error or login page. The error message says so; check the URL and whether you’re signed in.
  • Two colons or values in a row like {"a": "b": 1}, where the intended structure is unclear.
  • Mismatched quotes in the middle of text. The tool points to the line; the fix is yours.

Warnings on valid JSON

  • Duplicate keys. JSON allows the same key twice in one object, but most programs keep only the last value. The tool names the key and its line.
  • Numbers too big for JavaScript. Integers beyond 9,007,199,254,740,991 lose digits in JavaScript and many other tools. The formatter keeps them exact and warns you.

Format, minify and sort

Format puts each value on its own line, indented with 2 spaces, 4 spaces or tabs. Minify removes every space and line break between values, for the smallest file to send or store; spaces inside text stay. Sort keys A–Z orders the keys in every object, which makes two versions of the same data easy to compare.

Questions

How do I fix invalid JSON?

Paste it here. With Fix common errors on, the tool repairs trailing commas, single quotes, unquoted keys, comments, Python values like True and None, and missing brackets, then lists every change. When it can't guess the fix, it shows the exact line and column of the problem.

Why is my JSON invalid?

The usual causes are a comma before } or ], single quotes instead of double quotes, keys without quotes, comments, or a missing comma or bracket. JSON is stricter than JavaScript, so an object that works in a .js file can still be invalid JSON.

Can JSON have comments?

No. Standard JSON has no comments, so parsers reject // and /* */. Some config formats built on JSON, like JSONC and JSON5, allow them. The formatter removes comments when Fix common errors is on.

Are trailing commas allowed in JSON?

No. A comma before } or ] makes JSON invalid, even though JavaScript accepts it. The formatter removes trailing commas and tells you which lines had them.

What is the difference between formatting and minifying JSON?

Formatting adds line breaks and indentation so people can read the JSON. Minifying removes every space between values so the file is as small as possible to send or store. The data stays the same either way.

Is it safe to paste JSON with private data here?

The JSON never leaves your browser: formatting and repair run on your device, and nothing is uploaded or saved. Still, take care with API keys and passwords wherever you paste them.

Updated October 23, 2026 · Works in current Chrome, Edge, Firefox and Safari · Runs entirely in your browser