Guides › Developer
Why won't my JSON file load?
A program refuses to start because of its settings file, an import fails, or an API answers “invalid JSON”. The message rarely says more than a position, and JSON is strict about details that look harmless. These tools find the problem, explain it in plain words and check that the data has what the program expects, all in your browser.
1. Find the error
Paste the file into the Data Validator, or drop it on the page. It’s checked as you type, the problem is underlined, and the list under the text gives its line and column with what’s wrong. Most failures are one of a few slips:
- A missing comma between two items:
{"a": 1 "b": 2}givesExpected “,” or “}”, found “"”: is a comma missing before it? - A comma after the last item,
[1, 2,], which JavaScript allows and JSON doesn’t. - Single quotes or keys without quotes, such as
{name: 'web'}, copied from JavaScript or Python. - Comments,
//or/* */, which many settings files allow but JSON doesn’t. - A bracket that doesn’t match, where an object
{is closed with]: the message names the line the opening bracket is on, which is usually where the mistake is.
A duplicate key is a warning rather than an error: most programs keep the last one silently, which may not be the one you meant.
2. Repair the common slips
When the file is meant to be strict JSON and the errors are comments, trailing commas, single quotes, keys without
quotes or Python’s True, False and None, paste it into JSON Format and choose Prettify. It
repairs them and says what it fixed. A missing comma or bracket still needs fixing by hand, since only you know
where it belongs.
Check what the program reads before repairing. Some files, such as VS Code’s settings.json and tsconfig.json,
are JSON with comments, and taking the comments out loses your notes for nothing.
3. Check it has what the program expects
Valid JSON can still be wrong: a port written as "8080" instead of 8080, a required setting left out, a
misspelt key that the program quietly ignores. A JSON Schema describes what a file should contain, and many
programs and APIs publish one in their documentation.
In the Data Validator, open Check against a JSON Schema and paste the schema, as JSON or YAML.
Each problem is named by its path and marked where it is, such as $.server.port should be a whole number, not
text. The same check works on YAML and TOML files, as they hold the same kinds of data.
No schema? Make one from a file you know works: paste it into JSON to Types, choose To JSON Schema,
and check the failing file against the result. The schema only knows what was in that sample, so review it first:
take optional keys out of required, loosen anything that’s allowed to vary, and add "additionalProperties": false
to an object to catch misspelt keys.
4. Find your way round a large file
In JSON Format, Tree shows the file as an outline you can open and close. Choose any value to see its
path, such as $.items[2].price, and Copy path to use it in the JSONPath query box or in your own code.
Size and structure says how deeply the file nests, how many values it holds, and which parts take up the most
space, which helps when a file is too large for a program’s limit.
All 62 guides, grouped by what they help with.
Saved you a few minutes? Say thanks with a coffee.
Something wrong or unclear in this guide? Report it or suggest a guide.