Quick answer

A JSON formatter parses the input and serializes it with consistent indentation. If parsing fails, the content is not valid JSON even if it resembles a JavaScript object. JSON requires double-quoted property names and strings, forbids trailing commas and comments, and supports a limited set of value types.

How to do it

  1. Paste the complete document and run validation before editing individual lines.
  2. Use the reported position to check nearby quotes, commas, brackets, and escapes.
  3. Format only after parsing succeeds, then compare data types with the source requirements.

JSON is stricter than JavaScript

Single quotes, undefined, NaN, Infinity, functions, comments, and unquoted keys are not part of JSON. Convert them intentionally rather than applying blind text replacements that may change string content.

Formatting does not validate a schema

Syntactically valid JSON can still contain the wrong fields, types, dates, or identifiers. A formatter checks grammar; application-level validation requires a documented contract or JSON Schema.

Common mistakes to avoid

  • Deleting all trailing commas with a broad regular expression.
  • Assuming a formatted document meets an API schema.
  • Losing large integer precision after parsing in JavaScript.

Try the related tool

Use QRFoundry directly in your browser. Tool inputs and uploaded files are processed on your device.

Open JSON Formatter