Skip to content

JSON Formatter & Validator

Pretty-print, minify, and validate JSON.

Strict JSON only. Trailing commas, comments, and single quotes are reported as errors. Nothing you paste is uploaded.

Results

Paste JSON, then Format to pretty-print or Minify to compact it. Your data stays on this device and is never sent anywhere.

How the JSON formatter works

This tool does three jobs on the text you paste: it validates it, pretty-prints it, and minifies it. All three share one parser, so they always agree on whether your input is valid JSON. Validation runs the input through the browser’s built-in JSON.parse. If parsing succeeds, the value is then re-serialized either with indentation (Format) or with no extra whitespace at all (Minify). If parsing fails, the tool reports the exact location of the first problem instead of producing output.

The standard it enforces is strict JSON, the data format, not JavaScript object literals. That means keys must be double-quoted strings, strings use double quotes only, there are no trailing commas, and comments are not allowed. Holding to the standard is the point: it is what guarantees the output will be accepted by every other JSON parser, in any language.

When parsing fails, the error message includes a line and column so you can jump straight to the mistake. The position is the first character the parser could not accept, counting from 1. Indentation is your choice of two spaces, four spaces, or a tab.

Worked example

Paste this object and press Format with a two-space indent:

{"a":1,"b":[2,3]}

The tool parses it, confirms it is valid, and returns:

{
  "a": 1,
  "b": [
    2,
    3
  ]
}

Now press Minify on that pretty version. It collapses back to the compact single line {"a":1,"b":[2,3]}, which is byte-for-byte what you started with.

Next, try an invalid value:

{a:1}

The key a is not wrapped in double quotes, so this is not valid JSON. The tool reports an error at line 1, column 2, which is the position of the a, the first character the parser cannot accept. Add the quotes to make it {"a": 1} and Format succeeds.

How to use it

  • Paste or type JSON into the input box.
  • Pick an indent of two spaces, four spaces, or a tab.
  • Press Format to pretty-print, or Minify to compact it to one line.
  • If the input is invalid, read the line and column, fix that spot, and try again.
  • Copy the output from the result box when you are done.

Limitations

This tool validates and reformats JSON; it does not repair it. If a value is malformed, you fix the location it points to rather than having it guessed for you, which avoids silently changing your data. It also does not convert other formats such as JSON5, YAML, or JavaScript objects with unquoted keys, since those are different syntaxes. Very large documents are formatted in memory in your browser, so extremely large files may be slow on a low-powered device. The output is always standard JSON, ready to paste anywhere a strict parser is used.

Frequently asked questions

Why does it reject my JSON when it looks fine?

This tool follows the strict JSON standard, not relaxed JavaScript object syntax. Three things trip people up most often. Keys must be wrapped in double quotes, so {a: 1} has to be {"a": 1}. Trailing commas are not allowed, so [1, 2, 3,] must drop the last comma. Comments are not part of JSON, so // and /* */ are treated as errors. Single quotes are also invalid; only double quotes mark a string.

What does the line and column in the error mean?

They point to the first character the parser could not accept, counting from 1. Line 3, column 10 means the tenth character on the third line is where parsing broke. Often the real mistake is just before that spot, for example a missing comma or quote on the previous token, because the parser only notices the problem when it reaches the next unexpected character.

What is the difference between Format and Minify?

Format pretty-prints your JSON with line breaks and indentation so it is easy to read and review. Minify strips every space and newline that is not part of a string, producing the smallest single-line version, which is what you want for sending over a network or storing compactly. Both validate the input first, so you only get output when the JSON is well-formed.

Does formatting change my data or reorder keys?

No. The values are parsed and re-serialized exactly as written, in the same order, so numbers, strings, booleans, null, and the order of object keys are all preserved. Only whitespace changes. One detail worth knowing: JSON has no negative zero, so -0 becomes 0, which is standard behavior for every JSON parser.

Is my data sent anywhere?

No. The entire tool runs in your browser using the built-in JSON parser. Nothing you paste is uploaded, logged, or stored on a server, which matters when you are formatting payloads that contain tokens, personal details, or other sensitive values.