Practical tool guide · Published

JSON Syntax vs JSON Schema: What Does Valid JSON Mean?

A JSON document can parse perfectly and still violate your API contract. This guide distinguishes parser errors from validation rules and shows how to troubleshoot both.

Illustrated example for JSON Validator: {"active": true,} compared with {"active": true}
Example workflow for JSON Validator: json validation with sample input and result.
Quick answer

Use JSON Validator to check whether the text parses. Use JSON Schema Validator when you also need required fields, expected types, or numeric constraints. Try JSON Validator.

Start with the JSON grammar

JSON strings require double quotes, keys must be strings, and commas only separate items. The object {"active":true,} fails because it has a trailing comma. Comments and undefined are not standard JSON values.

A syntax validator reads the full document and reports whether parsing succeeds. A root value can be an object, array, string, number, boolean, or null; JSON does not require every document to start with an opening brace.

Why valid syntax is not enough

Consider {"price":"free"}. It is valid JSON syntax, yet a checkout API requiring a nonnegative numeric price would reject it. A schema specifies shape and constraints separately from syntax.

The JSON Validator checks syntax and identifies the root type. For required properties, enum values, array items, or minimum values, move to the JSON Schema Validator. A schema test is only as useful as the schema that describes your real contract.

A repeatable debugging order

First copy a failing payload into the validator; find the earliest parser error instead of guessing which downstream field caused the failure. Fix quoting, commas, braces, and invalid escape sequences.

Once syntax passes, inspect the expected root type and any schema rules. Then compare example values: the strings "42" and the number 42 look similar in a UI but are different JSON types. Retest after each change so a syntax fix does not hide a business-rule error.

  • Do not paste authentication tokens or secrets into shared issue reports.
  • Preserve examples with representative but non-sensitive values.

Watch for encoding and duplicate keys

A visually correct document can fail if it contains an unescaped control character inside a string. Replace literal line breaks in a JSON string with the two-character escape \n where appropriate.

Also note that ordinary parser validation does not flag repeated object keys as an error. If a source uses {"role":"viewer","role":"admin"}, a parse-and-serialize step can discard the earlier value. Use a specialized duplicate-key check when that risk matters.

Common questions

Does valid JSON mean my API will accept it?

No. The endpoint may require particular fields, types, and constraints.

Are JSON comments supported?

No. Standard JSON has no comment syntax.