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 the same unless you tick Sort keys, which puts the keys in each object in alphabetical order. That helps when you’re comparing two versions of a file. Items in arrays are never reordered. The JSON format guide covers the rules JSON has to follow.
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, with Python (add --sort-keys to sort keys)
python3 -m json.tool data.json
# Command line, with jq (use jq -S . to sort keys)
jq . data.jsonFinding and fixing errors
The editor checks your JSON as you type and underlines the first problem. The message under the editor gives the line and column, and clicking it takes you there. For common mistakes, like a comma after the last item, single quotes or a key without quotes, the message also links to a page about the fix.
Fix My JSON repairs those, along with other mistakes that are common in JSON typed by hand or copied out of code: 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, formatted version, so read it over before you use it. If it can’t find a fix, it tells you which line to look at. For a file or response that was cut off, it closes the open brackets so you can read what’s there, but it can’t bring back the missing part.
To see every change listed before you accept it, or to pull JSON out of a ChatGPT reply, use JSON repair. For an error from your own code, such as Unexpected token in JavaScript or Expecting value in Python, look it up on the JSON errors page.
Exploring the result
Tree lets you fold objects and arrays and copy the path to any value, such as .schedule[0].start, to use in your code. Query takes a jq-style filter like .schedule[].day and shows only the matching values. Open in sends the result to Compare JSON, JSON to YAML, JSON to CSV or the JSON Schema validator without pasting it again.
Sharing JSON with a link
Share copies a link that contains your JSON, so whoever opens it sees the same thing. Nothing is uploaded. The JSON is compressed into the part of the link after the #, which browsers don’t send to the server.
The link isn’t encrypted, so anyone who has it can read the JSON. Remove anything private before you share it. Large documents make long links, and some chat apps cut those off. The privacy policy explains what the site does and doesn’t keep.