Skip to main content
Develop Tools
← Return to usage guide

How to Validate JSON with JSON Schema and Locate Errors

Writing a JSON Schema alone does not prove that real API requests or configuration JSON satisfy it. Validate both valid and invalid JSON and compare the instance and Schema locations to catch specification mismatches before implementation.

Workflow for entering JSON and JSON Schema, locating errors, and correcting them
Workflow for entering JSON and JSON Schema, locating errors, and correcting them

What to check before validation

  • Both the JSON and JSON Schema use valid JSON syntax
  • $schema matches the Draft used by the actual validator
  • Required definitions are included locally rather than referenced through an external $ref
  • You have decided whether format is an annotation or a constraint

How to validate with JSON Schema

  1. Paste or open the JSON to validate on the left and the JSON Schema on the right.
  2. Choose the Schema specification, format mode, Schema self-validation, and error limit.
  3. Run validation and review validity, error count, warnings, and processing time.
  4. Select an error to move to the input or Schema location identified by its JSON Pointer.
  5. Validate again after editing and confirm that the error is resolved.

How to read validation errors

instanceLocation points to the JSON being validated, while keywordLocation points to the violated Schema keyword. For errors such as required, where the value does not exist, instanceLocation points to the parent object.

anyOf and oneOf errors occur when no branch matches or, for oneOf, when multiple branches match. Also check whether branch conditions overlap.

If the Schema syntax or keyword values are invalid, correct the Schema before changing the data.

Example: Validate input JSON for a customer registration API

A customer registration API can define id as a positive integer, email as an email-formatted string, and tags as a unique string array. An id of 0, an invalid email, and duplicate tags trigger minimum, format, and uniqueItems errors respectively.

Comparing the JSON and Schema locations in the error list helps determine whether the value is wrong or the Schema constraint is too strict.

  1. Prepare test JSON without personal information and the JSON Schema currently in use.
  2. Use automatic detection when $schema is present, or choose the Draft explicitly when needed.
  3. Select strict validation only when format should be enforced as a constraint.
  4. After validation, select an error and correct the corresponding JSON or Schema location.

External $ref resources are not fetched. For shared validation, combine required definitions into one Schema using $defs or a similar mechanism.

Frequently asked questions

What does it mean to treat format as an annotation?
Draft 2020-12 can treat format as an annotation. Enable strict format validation when email or date-time strings must be enforced as constraints.
Can the tool validate a $ref that points to an external URL?
No. The tool makes no external requests. Move referenced definitions into $defs or bundle them into a single Schema before validation.

Try It in Your Browser

Your input is processed entirely in your browser. Keep the original data, review the output, and only then save or share it.

Open the JSON Schema Validator