โœฆ Developer Tool ยท Interactive
โ† Back to dev

JSON Validator

Check JSON against strict syntax rules and see the exact line where it fails. Catch trailing commas, single quotes, missing brackets and stray comments.

{ } Developer Toolโšก Instant result
</>
{ } 01 ยท DEVELOP

Why your JSON is invalid: common errors

An "Unexpected token" message tells you something is wrong but rarely what. A JSON validator parses your text against the strict standard, RFC 8259. It points to the line and column where parsing fails. Most problems fall into a handful of patterns.

ErrorInvalidValid
Trailing comma{"a": 1,}{"a": 1}
Single quotes{'a': 1}{"a": 1}
Unquoted key{a: 1}{"a": 1}
Comment in file{"a": 1 // id}{"a": 1}
Wrong literal case{"ok": True}{"ok": true}
Undefined or NaN{"x": NaN}{"x": null}

Most of these come from writing JSON by hand or copying JavaScript objects. Python users meet the True and None problem often. That is because printing a dictionary shows Python syntax, not JSON.

Reading the error message

Parsers report where they gave up, not always where the mistake began. If the validator flags line 40, look at line 39 as well. A missing comma at the end of one line often surfaces as an unexpected string on the next.

Unclosed brackets are the trickiest case. The error may appear at the very end of the file with "Unexpected end of input". Count opening { and [ against their closing partners, or format the valid portion to see where the nesting drifts.

Errors that hide in copied text

Some problems are invisible. A byte order mark, a non-breaking space or curly quotes from a word processor all look normal on screen. If the error points to a spot that seems fine, retype that character by hand. Saving files as UTF-8 without a BOM also prevents trouble.

Fixing a broken payload step by step

  1. Paste the full text, including the first { or [. Partial copies from logs often miss the opening bracket.
  2. Fix the first error reported, then validate again. One mistake can trigger a chain of later false alarms.
  3. Replace smart quotes copied from Word or Slack with plain double quotes.
  4. Escape any double quote or backslash inside a string as \" or \\.
  5. Once the validator shows the JSON as valid, format it for review or minify it for production.

Syntax validation vs JSON schema validation

A syntax check only confirms the text is well-formed JSON. It will happily accept {"age": "twenty"} even if your API expects a number. Schema validation is a separate step. It checks types, required fields and allowed values against a JSON Schema document.

Use the ToolsMate JSON validator for the first job. It catches typos before they break a deploy, config file or webhook. For contract testing between services, add a schema validator such as Ajv to your build. Together, the two checks catch both broken syntax and wrong data.

A quick syntax check pays off in a few common places. Try it on package.json before an npm install and on a webhook body before a test call. JSON-LD schema deserves a check before every site release.

</> 02 ยท UNDERSTAND

How this developer tool works

01

Enter the required information

Use the fields in the tool above and keep units and formats consistent.

02

Run the tool

Review the result shown in the output area.

03

Check the assumptions

Confirm that the result matches your situation before using it for a decision.

</> 03 ยท FORMULA / LOGIC

Which formula or logic is used?

</>The input is parsed as JSON; parsing success means valid JSON.

This describes the core logic used by the tool. Check any assumptions that may affect your result.

โœฆ 04 ยท IMPORTANT

Things to know before using JSON Validator

01

Use accurate inputs and keep units consistent.

02

Review the assumptions before using the result for a decision.

03

Compare important results with an independent or official source.

? 05 ยท FAQ

Frequently Asked Questions

Are trailing commas allowed in JSON?+

No, standard JSON does not allow a comma after the last item in an object or array. JavaScript and some config formats such as JSON5 accept them. That is why this error appears so often when people copy code into JSON files.

Can JSON contain comments?+

Strict JSON has no comment syntax. Lines starting with double slashes, or blocks in slash-star form, cause a parse error. Formats like JSONC, used by VS Code settings, allow comments, but standard parsers will reject them.

Why does my JSON say unexpected token at position 0?+

Position 0 means the very first character is wrong. Common causes are an HTML error page returned instead of JSON, or a byte order mark at the file start. An empty response body from the server also triggers it.

Does JSON require double quotes around keys?+

Yes, every key must be a string wrapped in double quotes. Single quotes and bare words are valid in JavaScript object literals, but a JSON parser rejects them. String values follow the same double-quote rule.

How can I check if JSON is valid in JavaScript?+

Wrap JSON.parse in a try and catch block. If parsing succeeds, the text is valid and you get the object back. If it throws a SyntaxError, the message usually includes the position of the problem character.

Is null a valid JSON value?+

Yes, null is one of the valid JSON literals alongside true and false, and it must be lowercase. JavaScript values like undefined, NaN and Infinity are not valid, so serialisers usually convert them to null or drop them.

What is the difference between JSON validator and JSON lint?+

In everyday use the terms mean the same thing: a check that the text follows JSON syntax. JSONLint is the name of a popular tool. Many people now use it as a general word for JSON validation.

โ—Ž 08 ยท CATEGORY HUBS

Explore TheToolsMate