Skip to content
toolwise

JSON Formatter

Format, validate and beautify JSON with clear error messages.

Result
 

When to use it

The JSON formatter turns hard-to-read JSON into neatly indented text, checks that it’s valid, and points to the exact line and column of any error. Use it when an API returns one long unreadable line, when a configuration file won’t load, when you need to inspect a webhook payload, or when you want the smallest possible version of a file for production.

How to format JSON

  1. Paste your JSON into Your JSON, press Open file to load a .json file, or press Example to try it out.
  2. Choose Format to make it readable or Minify to make it compact.
  3. For formatting, pick the Indentation: 2 spaces, 4 spaces or Tabs.
  4. Tick Sort keys A–Z to put object keys in alphabetical order.
  5. Read the Result, then press Copy result or Download .json.

If the JSON isn’t valid, you’ll see where the problem is and a hint about what’s wrong.

A worked example

An API sends back this single line:

{"user":{"name":"Ana","roles":["admin","editor"],"active":true}}

With Format and 2 spaces, the result shows user on its own line with name, roles and active indented beneath it, and each role on a separate line, so the structure is clear at a glance. Now suppose you’d typed "active":true,} with a stray comma. The tool reports the line and column of the problem and suggests that there may be a trailing comma before a closing bracket.

Common JSON errors and fixes

  • Trailing comma: [1, 2, 3,] is invalid; remove the last comma.
  • Single quotes: {'name': 'Ana'} must be {"name": "Ana"}.
  • Unquoted keys: {name: "Ana"} needs quotes around name.
  • Missing brackets: every { needs a } and every [ needs a ].
  • Special values: undefined, NaN and dates aren’t JSON; use null, numbers or strings.

Tips

  • Use 2 spaces for most projects; it’s the most common style.
  • Minify only for machines. Keep a formatted copy for editing.
  • Sort keys before comparing two versions of a config file.
  • Very large files (tens of megabytes) may be slow on phones; use a computer.

Common mistakes

  • Pasting JavaScript objects rather than JSON; JavaScript allows things JSON doesn’t, like comments and single quotes.
  • Copying from a web page or chat app, which can turn straight quotes into curly “smart” quotes.
  • Assuming valid JSON means correct data. The formatter checks syntax, not whether the values make sense.

Convert JSON for spreadsheets with JSON to CSV, go the other way with CSV to JSON, or encode data for URLs with the Base64 Encoder and Decoder.

Frequently asked questions

What's the difference between formatting and minifying?

Formatting adds line breaks and indentation so people can read the structure. Minifying removes all unnecessary spaces and line breaks to make the file as small as possible for machines. Both contain exactly the same data.

Why does it say there's a problem on a certain line?

The text isn't valid JSON at that point. The most common causes are a missing comma between items, a comma after the last item, single quotes instead of double quotes, or a missing closing bracket. The message suggests the likely fix.

Can it handle comments in JSON?

No. Standard JSON doesn't allow comments, so files with // or /* */ comments are reported as invalid. Remove the comments first.

Is my data sent to a server?

No. Your JSON is checked and formatted in your browser, which makes the tool safe for API responses, config files and data containing personal or secret information.

What does "Sort keys A–Z" do?

It puts the keys of every object in alphabetical order. That makes large objects easier to scan and makes two versions easier to compare.