Format before you debug

Minified API responses hide structure. Pretty-printing adds indentation and line breaks without changing values, making nested objects and arrays easier to scan.

A formatter should parse before it prints. If parsing fails, fix the first reported syntax error before chasing later messages because one missing quote or comma can shift the rest of the document.

Common JSON syntax failures

Strict JSON is smaller than JavaScript object syntax. It rejects several conveniences developers often type from habit.

  • Property names must use double quotes.
  • Strings must use double quotes, not single quotes.
  • Trailing commas are not allowed.
  • Comments, undefined, NaN and functions are not JSON values.

Protect production payloads

Authentication tokens, customer records and unreleased API responses should not be pasted into tools that send data to a server. Prefer converters that operate locally and confirm the browser network panel stays quiet when your data is sensitive.

Try a valid fixture, then introduce one error

Paste this compact fixture into JSON Formatter and keep two-space indentation. The result below makes the two records visible. Copy the same source into JSON Validator: the root is an object containing an array, not a flat table. Both tools parse the entire document before producing a result.

Now add a comma after the second record, before the closing square bracket. Validation must fail. Remove that comma rather than trying to repair the formatted output; there is no valid output until the source parses. Error wording varies between browser engines, so compare the location and offending punctuation rather than expecting an identical sentence.

Input · JSON Formatter
{"items":[{"id":1,"active":true},{"id":2,"active":false}]}
Expected output · two spaces
{
  "items": [
    {
      "id": 1,
      "active": true
    },
    {
      "id": 2,
      "active": false
    }
  ]
}
Invalid variant · trailing comma
{"items":[{"id":1,"active":true},{"id":2,"active":false},]}

Check what parsing can change

XXF uses JavaScript JSON.parse and JSON.stringify. These preserve ordinary parsed values, but they are not a byte-preserving editor: escape spelling and number notation may change, and duplicate property names cannot survive as separate entries in a JavaScript object. Large integer literals beyond JavaScript's safe integer range can lose precision before formatting even starts.

Keep identifiers such as long account numbers as strings when the contract permits it. If exact numeric spelling, duplicate keys or signed request bytes matter, use an appropriate lossless parser or inspect the original bytes. Do not hash or sign the formatted copy and expect the original document's digest to match.

  • Compare record counts and nesting before copying
  • Use strings for identifiers that are not arithmetic values
  • Keep the original source when exact bytes matter
  • Formatting is not JSON Schema validation
Primary references

Read the specification

RFC Editor · RFC 8259The JavaScript Object Notation Data Interchange Format↗MDN Web DocsJSON.parse()↗

Put the guide into practice

Open the related browser tools and test the workflow with a synthetic sample

JSON Formatter ↗JSON Validator ↗JSON Minifier ↗JSON Key Sorter ↗