Skip to content

JSON formatter

Format JSON so you can read it, and see a plain error when the text is not valid JSON.

Short answer

Valid JSON is parsed and printed with two-space indentation. Invalid JSON stops with a short error. Nothing is evaluated as a program.

How this works

The formatter uses a JSON parser. It accepts objects, arrays, strings, numbers, true, false, and null. It does not accept comments, trailing commas, or single-quoted strings, because those are not JSON.

Text stays in the browser. The page does not need an account, and it will not run functions hidden in the text. There is a size limit so a huge paste cannot lock the page.

Examples

  • A trailing comma

    {"ok": true,} fails. Remove the comma before the closing brace.

Common mistakes

  • Pasting JavaScript object literals and expecting them to format. Keys must be double-quoted strings.

Frequently asked questions

Will this fix the JSON for me?
No. It tells you the text is invalid. Guessing a repair can hide a real bug.

Related

Sources