JSON Formatter & Validator
Paste JSON to check it, format it, or fix it. It all happens in your browser.
How to format JSON
- Paste your JSON above, or choose Open file to load a
.jsonfile. - Choose Format, with 2 spaces, 4 spaces, or tabs for each level.
- 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.jsonChecking 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.
Fixing broken JSON
Fix My JSON repairs the mistakes that turn up most when JSON has been typed by hand or copied out of code: a comma after the last item, single quotes, keys without quotes, comments, Python’s True, False and None, a missing comma between items, and brackets that were never closed. It replaces your text with the repaired version and formats it, so read it over before you use it. If it can’t work out a fix, it tells you which line to look at.
If a file or API response was cut off partway through, Fix My JSON closes the open brackets so you can read what’s there, but it can’t bring back the missing part. You’ll need to download or export it again.
Exploring the result
The result has three views. Text is the formatted JSON. Tree lets you fold objects and arrays open and closed, and copy the path to any value, like .projects[0].title, which is useful when you’re writing code that reads it. Query takes a jq-style filter such as .items[].name and shows only the values that match.
Open in sends the result straight to Compare JSON, JSON to YAML, JSON to CSV, or the JSON Schema validator, so you don’t have to paste it in again.
Sharing JSON with a link
Share copies a link with your JSON packed into it. Whoever opens it sees the same JSON in their browser. Nothing is uploaded: the JSON is compressed and kept in the part of the link after the #, which browsers don’t send to the server.
The link isn’t encrypted, though, so anyone who has it can read the JSON. Leave out anything private before you share. Very large documents also make very long links, and some chat apps cut those off. The privacy policy explains what the site does and doesn’t keep.