Skip to content
MyToolers

JSON Formatter & Validator

Beautify, minify and validate JSON — errors shown with the exact line and column.

About this tool

Paste JSON from an API response, config file or log and format it with readable indentation, compress it to a single line, or check that it is valid. If the JSON is broken, you get the exact line and column, the broken line with a marker under the problem, and a plain-English reason such as a trailing comma or a missing quote. You can also sort keys A–Z to compare two JSON files more easily.

How to use it

  1. Paste JSON into the input box.
  2. Choose Format (2 or 4 spaces) or Minify — tick “Sort keys A–Z” first if you want keys in alphabetical order.
  3. Fix any reported error, then copy the result.

Good to know

  • Validation uses the browser's built-in JSON parser, so it follows the official JSON standard.
  • Comments and trailing commas are not valid JSON and will be reported as errors.
  • Errors show the line and column, the line itself with a ^ under the problem, and the likely cause.
  • Sorting keys works at every level of nesting; array order is never changed.
  • Valid JSON also shows stats: how many keys, objects, arrays and values it has, how deeply it is nested, and its size before and after formatting.
  • Nothing you paste is sent to a server.

Reading JSON quickly

JSON from an API usually arrives minified — one long line with no spaces. Formatting it with indentation shows which values belong to which object, how arrays are nested and where a bracket is missing. Minify it again before sending it if file size matters.

The errors you will see most

Single quotes around strings or keys (JSON needs double quotes), a comma after the last item, keys without quotes, comments, and values such as undefined or NaN. The error message points to the position where parsing failed — the real mistake is usually just before it.

Example: {"name": "Ali", "age": 30,} fails because of the comma after 30. Removing it makes the JSON valid.

Keep sensitive data private

API responses often contain tokens, emails or customer data. This formatter checks your JSON inside your browser and sends nothing to a server, but it is still good practice to remove secrets before sharing formatted JSON with anyone.

Finding the exact error

Browsers word JSON errors differently, and some don't say where the problem is. This formatter checks the text itself and reports the line and column, shows that line with a ^ marker, and names the likely cause — “Trailing comma”, “Property names must be in double quotes”, “Is a comma missing?” and so on.

For example, a missing comma between "a": 1 and "b": 2 is reported at the start of "b", because that is where a comma or closing brace was expected.

Why sort keys?

Two JSON files with the same data can list keys in a different order, which makes them look different in a text comparison. Sorting keys A–Z at every level puts both in the same order, so a diff shows only real changes. Arrays keep their order, because in JSON the order of array items is part of the data.

Frequently asked questions

How do I find the error in my JSON?

Press Format. If the JSON is invalid, the tool shows the line and column, prints that line with a ^ marker under the problem and explains the likely cause.

Why does my JSON show an error?

Common causes are single quotes instead of double quotes, trailing commas, unquoted keys, comments and a missing comma between two values.

What is the difference between formatting and minifying?

Formatting adds line breaks and indentation so people can read it. Minifying removes all unnecessary spaces so the JSON is as small as possible for sending or storing.

Is it safe for private data?

Yes. Formatting runs locally in your browser and the data never leaves your device.