Practical tool guide · Published

How to Validate Required Fields and Types With JSON Schema

JSON parsing catches punctuation errors; a schema catches data that is structurally valid but incompatible with your contract. This walkthrough uses a small object and clear constraints.

Illustrated example for JSON Schema Validator: {"age":"19"} compared with {"age":19}
Example workflow for JSON Schema Validator: json schema with sample input and result.
Quick answer

Provide a JSON instance and a JSON Schema with type, required, properties and any relevant constraints. Read the reported property paths, correct the data, then rerun validation. Try JSON Schema Validator.

Write a minimal, useful schema first

Imagine a registration payload with name and age. Valid JSON such as {"name":"Sam","age":"19"} may be wrong if the application expects age to be an integer. A schema can declare an object, require the two keys, and specify properties.name as string and properties.age as integer with a minimum of zero.

Start with the contract the receiving system actually enforces. A schema that says only type: object proves very little; a schema that forbids all unknown properties may be too strict for evolving payloads.

Validate data and read the error path

Paste the JSON instance into the first input and a schema into the separate schema input. Run validation and inspect the path in the error message. A missing required name is different from an age field that exists with the wrong type.

The ConvertAnyFile validator supports common keywords including required, properties, additionalProperties, items, enum, const, minimum/maximum, pattern, local $defs references and basic combinators. It is not a complete implementation of every JSON Schema 2020-12 feature.

Fix a type mismatch without guessing

Given {"age":"19"}, the number is wrapped in quotes and so is a string. If the schema expects integer, the correct JSON representation is {"age":19}, provided your data source really represents a number.

Do not blindly strip quotes from fields such as postal codes, order numbers or telephone numbers. These may look numeric while still being identifiers that must stay strings.

  • Keep a passing example payload alongside the schema.
  • Test both a passing and failing sample for each important rule.

Know where this tool stops

External $ref resolution, advanced schema annotations and format assertions are outside the supported subset. For a production contract that relies on those features, use a fully compatible validator and test the same example there.

Schema validation also does not establish that an email address exists or that a customer's identity is verified. It checks declared structure and constraints, not real-world truth.

Common questions

Is JSON Validator the same as JSON Schema Validator?

No. The former checks syntax; the latter checks selected structural rules.

Does this support remote $ref URLs?

No. Only supported local references are handled.