Skip to content
JSON Tidy

JSON Formatter & Validator

Paste JSON to check it, format it, or fix it. It all happens in your browser.

How to format JSON

  1. Paste your JSON above, or choose Open file to load a .json file.
  2. Choose Format, with 2 spaces, 4 spaces, or tabs for each level.
  3. Copy or download the result.

Formatting, also called pretty-printing or beautifying, only changes spaces and line breaks. Keys, values, and their order stay exactly as they were, unless you tick Sort keys. That puts the keys in each object in alphabetical order, which helps when you’re comparing two versions of a file. Items in arrays are never reordered. If the JSON has a mistake, the editor underlines the line, and Fix My JSON can repair common ones. For the rules behind it all, read the JSON format guide.

Formatting JSON in code

// JavaScript
JSON.stringify(data, null, 2)

# Python (add sort_keys=True to sort keys)
json.dumps(data, indent=2)

# Command line (jq -S . sorts keys)
python3 -m json.tool data.json
jq . data.json

Checking JSON for errors

The editor checks your JSON as you type and underlines the first problem it finds. The message under the editor gives the line and column, and clicking it takes you there. For the mistakes that come up most, like a comma after the last item, single quotes, or a key without quotes, the message also links to a page that explains the fix. Fix My JSON can repair most of those for you.

If you’ve got an error from your own code instead, such as Unexpected token in JavaScript or Expecting value in Python, look it up on the JSON errors page.

Have a suggestion or found a bug? Send a message.

We’ll only use your email to respond to this message.