JSON Formatter

Pretty-print, minify, or validate JSON in your browser. Nothing is uploaded or stored.


A JSON formatter turns compact or messy JSON into indented, readable text, and a JSON validator tells you whether text is valid JSON and where it breaks. This tool does both, plus minifying. It runs with your browser's built-in JSON.parse and JSON.stringify; nothing you paste is sent to PagesTest.

How to format or validate JSON

  1. Paste JSON into the box: an API response, a config file or a log line.
  2. Click Format to pretty-print it with 2-space indentation, Minify to put it on one line, or Validate to check the syntax without changing it.
  3. If the JSON is invalid, the error message gives the position, and in most browsers the line and column, where parsing stopped. The real mistake is usually just before that point.

Common JSON errors and how to fix them

MistakeInvalidValid
Trailing comma{"a": 1,}{"a": 1}
Single quotes{'a': 'x'}{"a": "x"}
Unquoted keys{a: 1}{"a": 1}
Comments{"a": 1 // note}Remove the comment; JSON has no comments
JavaScript-only valuesundefined, NaN, Infinitynull or a number
Raw line break inside a stringA string split over two linesUse \n inside the string

An error at position 0 or 1 often means the text isn't JSON at all, for example an HTML error page returned by an API instead of the response you expected.

Does formatting change my data?

Formatting only changes whitespace, with three exceptions that come from how browsers parse JSON:

  • Very large integers lose precision. Numbers beyond ±9,007,199,254,740,991 (253−1), such as some 64-bit IDs, are rounded: 12345678901234567890 becomes 12345678901234567000. Keep such values as strings, or don't use the formatted output for them.
  • Duplicate keys collapse. If an object repeats a key, only the last value is kept.
  • Numbers and escapes are normalised. 1.50 becomes 1.5 and é becomes é. The values are the same; only their spelling changes.

Frequently asked questions

Is my JSON sent to a server?

No. Formatting, minifying and validating all happen in your browser, so the tool is safe to use with API responses that contain private data.

What does "Unexpected token" mean in JSON?

The parser found a character it didn't expect at that position, most often a trailing comma, a single quote, an unquoted key, or the start of an HTML page where JSON was expected.

What is the difference between formatting and minifying JSON?

Formatting adds line breaks and indentation so people can read it. Minifying removes all unnecessary whitespace so the JSON is as small as possible to send or store. Both describe exactly the same data.

Can JSON contain comments?

No. Standard JSON has no comment syntax. Some tools accept variants such as JSONC or JSON5 that allow comments, but this validator, like JSON.parse, follows the standard.