Skip to content
toolgrid

No tool found. Try another word.

JSON Formatter

Format and beautify JSON instantly: readable indentation (2, 4 spaces or tabs), optional sorted keys, and clear errors with the line and column.

Runs in your browser. What you enter is kept for 30 days to improve Toolgrid, then deleted.

How to use the JSON Formatter

  1. 1 Paste your JSON into the input box, or load the sample.
  2. 2 Choose the indentation and whether to sort the keys.
  3. 3 Copy the formatted JSON or download it as a file.

About the JSON Formatter

JSON from APIs, logs and configuration files often arrives on a single line, which makes it hard to read or debug. The JSON formatter parses your data and prints it again with consistent indentation, one property per line, so you can see the structure at a glance.

The formatter uses the same parser as your browser (JSON.parse), so what it accepts is exactly standard JSON: double-quoted keys and strings, no trailing commas and no comments. If the input is invalid, you get the parser's message with the line and column of the problem, so you can find a missing quote or comma quickly.

Sorting keys gives every object its properties in alphabetical order, at every level. That is handy for comparing two JSON documents or keeping configuration files tidy in version control. Arrays keep their order, because the order of array items is meaningful.

Frequently asked questions

Is my JSON sent to a server?

The formatting itself happens in your browser. As described on the privacy page, what you enter is logged for 30 days to improve Toolgrid, so don't paste secrets such as API keys.

Why do I get an error for valid-looking JSON?

Common causes are single quotes instead of double quotes, a comma after the last item, comments, or unquoted keys. These are allowed in JavaScript but not in JSON.

Does formatting change my data?

No. Only whitespace changes; with "sort keys" the order of object properties changes too, which has no meaning in JSON. Very large numbers beyond JavaScript's precision (more than 15–17 digits) can lose their last digits.

Should I use 2 or 4 spaces?

Both are fine. Two spaces is the most common style for JSON (npm, many APIs); four spaces or tabs can be easier to read in deeply nested documents.