JSON Formatter & Validator

Beautify, minify, and validate JSON instantly.

INPUT0 chars

When a JSON formatter is the right tool

JSON often arrives on one line: a log entry, a copied API response, or a minified manifest. It is hard to read, and a missing bracket is hard to find. A formatter is for that moment. You paste the text, choose Format, and get a two-space indented copy — or choose Minify when you need the compact form back. If the text is not valid JSON, the page shows the parser error instead of a guessed repair.

This page works on a single document. To compare two versions, use JSON Diff, which runs the same parse-and-pretty-print step on each side and then shows a line diff. To check a document against a schema, use the JSON Schema Validator. There is also a dedicated JSON Minifier if you only want the compressed form.

Use cases

Reading a minified API payload

A support log or a gateway response is often a single long line. Formatting it turns nested objects into an indented tree you can actually scan, and it confirms that the payload is valid JSON before you start arguing about a missing field.

Catching a syntax error before you commit

A trailing comma, a comment left in from a JSONC file, or a typo in a string will fail here with the parser's message. That is more useful than discovering the same mistake later in a build or an API client. Fix the text, then format again.

Producing a compact or a readable copy

Some tools want minified JSON; some reviews are easier with indentation. Both buttons start from the same parse, so you can go from compact to readable and back without changing the data. Load Sample pastes a small minified object if you want to try that round trip first.

How formatting works

Format and Minify both call JSON.parse on the input. If parsing fails, the error is shown and the output is cleared. If it succeeds, Format uses JSON.stringify with two-space indentation, and Minify uses JSON.stringify with no extra whitespace. The character count above the input is the length of what you pasted, not of the output. The result appears in a separate pane you can copy. Editing the input clears the previous output so you do not mix an old result with new text.

Key order is preserved from the input. Numbers may be rewritten in a canonical form (1.0 becoming 1, for example). Duplicate keys collapse to the last value. The output is plain text — there is no syntax highlighting, no foldable tree, and no indent-width setting.

Example — the same object, minified and formatted
{"name":"diffcheck","version":"1.0.0","author":{"name":"Ada"}}

{
  "name": "diffcheck",
  "version": "1.0.0",
  "author": {
    "name": "Ada"
  }
}

The two documents represent the same value. Format turns the first into the second. Minify turns the second back into a single line. Use whichever form the next tool in your workflow expects.

Example — a trailing comma that this page will reject
{
  "name": "diffcheck",
  "version": "1.0.0",
}

This is valid in JavaScript object literals and in some JSONC files, but it is not valid JSON. The parser will fail, and no output is produced until the comma after 1.0.0 is removed. Comments and single-quoted strings fail in the same way.

What this tool does not do

It does not validate a schema, sort keys, rewrite encodings, or repair broken JSON. It does not highlight syntax, and it does not send your document to a server. Very large files can still be pasted, but they may make the tab feel slow. To escape a string for use inside JSON, use JSON Escape rather than this formatter.

How to use JSON Formatter

  1. Paste your JSON into the input pane.
  2. Choose Format to pretty-print, or Minify to remove whitespace.
  3. If an error appears, fix the syntax and try again. When the output looks right, copy it from the output pane.
  4. Use Clear to start over, or Load Sample to try a short minified example first.

When you have two versions of the same document, format is not enough: open JSON Diff and paste them there. To turn the result into YAML, use the JSON to YAML converter.

Frequently asked questions

What is the difference between Format and Minify?

Both start by parsing the input with JSON.parse. Format writes it back with two-space indentation. Minify writes it back as a single line, with no extra whitespace. Either button will fail with a parser error if the input is not valid JSON, and the output pane stays empty until the text is fixed.

Does this page validate JSON Schema?

No. A successful format or minify only means the text parsed as JSON. It does not check required fields, types, or a schema document. Use the JSON Schema Validator page when you need that.

Does it accept comments, trailing commas, or JSON5?

No. The parser is standard JSON. A trailing comma, a comment, an unquoted key, or a single-quoted string is a syntax error. The page shows the parser message and does not produce output until the text is strict JSON.

Are object keys sorted?

No. Keys stay in the order they had in the input. Format and minify will not alphabetize properties. Duplicate keys collapse to the last value the parser kept, so a repeated key will not appear twice in the output.

Is there syntax highlighting?

No. The result is shown as plain monospaced text in an output pane you can copy. The page is a formatter and a syntax check, not an editor with colored tokens.

Is my JSON sent to a server?

No. Parsing and rewriting run in your browser. Closing the tab discards what you pasted. Do not paste documents that contain secrets if you would not be comfortable with them sitting in memory on this device.

Is there a file size limit?

There is no server-imposed limit, because nothing is uploaded. A few thousand lines is comfortable. Multi-megabyte documents can make the page feel slow; in that case, format a smaller excerpt or use a local tool.

Related tools and guides

References

  • RFC 8259 is the JSON format this page accepts. Comments and trailing commas are outside that grammar, which is why they fail here.
  • JSON.parse and JSON.stringify are the browser APIs used to validate, indent, and minify. The indent width is two spaces; there is no setting for tabs or a different width.
  • JSON Schema is the usual way to check structure and types after the text itself is valid. That check lives on a separate page of this site.