Free Online JSON Formatter and Validator

Paste any JSON below to pretty print it, minify it, sort its keys, or check it for syntax errors.
Everything runs in your browser. Your data is never uploaded.

Format or validate your JSON

Paste your JSON in the box, pick an indent size, then click one of the buttons.

Result

Here is your processed JSON. Click the button to copy it.

What Is JSON?

JSON stands for JavaScript Object Notation. It is a plain text format for storing and exchanging structured data. You can use it for API responses, configuration files and records that need objects, arrays and simple values.

The six JSON value types

  • Object: an unordered set of key and value pairs wrapped in curly braces. Keys must be strings in double quotes.
  • Array: an ordered list of values wrapped in square brackets.
  • String: text in double quotes. Single quotes are not allowed.
  • Number: an integer or decimal. No leading zeros, no hex, no NaN or Infinity.
  • Boolean: the literal words true or false, always lowercase.
  • Null: the literal word null.

Why format JSON?

Servers usually send JSON with all whitespace stripped to save bandwidth. That is great for machines and terrible for humans. Formatting, also called pretty printing or beautifying, adds line breaks and indentation so you can see the structure at a glance, spot a missing field, or diff two responses. Minifying is the reverse: it removes every unneeded space so the text is as short as possible before you store or send it.

Common JSON mistakes this tool catches

These examples cover errors you can check in your own input. Our guide to JSON syntax rules and 10 errors to fix explains each case.

  • Trailing commas: {"a": 1,} is valid JavaScript but not valid JSON.
  • Single quotes: {'a': 1} fails. JSON only accepts double quotes.
  • Unquoted keys: {a: 1} fails. Every key must be a quoted string.
  • Comments: JSON has no comment syntax. Lines starting with // or blocks in /* */ are errors.
  • Undefined and functions: these JavaScript values have no JSON form and cannot appear in the text.
  • Unescaped control characters: a raw line break inside a string must be written as \n.

JSON vs a JavaScript object

People often mix the two up. A JavaScript object lives in memory and can hold functions, dates and undefined. JSON is only text. When you call JSON.stringify the object is turned into text, and JSON.parse turns that text back into an object. The details and surprises are in JSON.stringify and JSON.parse explained. The rules of JSON are stricter than JavaScript, which is why code that looks fine in a script can still fail as JSON.

How this tool works

The formatter uses your browser's built in JSON.parse and JSON.stringify. If the parser provides a location or the input ends early, the error message shows the line and column. Other errors keep the browser's message. The Sort Keys button walks the whole structure. Array index keys such as "2" and "10" appear first in numeric order; other keys follow alphabetically. Sort both documents before comparing them. Nothing you paste ever leaves your computer. Prefer the terminal? See how to pretty print JSON from the command line. Need to check the shape of a document, not just its syntax? Read our introduction to JSON Schema, or draw the document with our JSON visualizer to see its structure as a diagram. The habits behind each button are in Inside our JSON formatter.

Copied!
↑ Top