What is JSON Schema? Validate API payloads and config files
By TechCompare · Updated · How we check
Use JSON Schema for public APIs where you can't control the client, for critical data pipelines where bad data is expensive, and for configuration files where a typo could break production. For internal microservices with shared type definitions (TypeScript, Protobuf), the schema adds overhead that may not be worth it.
JSON Schema is a vocabulary that lets you annotate and validate JSON documents. You define the expected shape of your data (required fields, types, value ranges, regex patterns) in a schema file, and any JSON document can be validated against it. It's the JSON equivalent of XML Schema or a database table definition.
How this is calculated
JSON Schema is used in OpenAPI specifications, editor support, and data validation. The schema describes expected data, but it doesn't validate payloads by itself. A validator can check sample data during a build or check each incoming request at runtime. A well-written schema also documents the fields an endpoint expects. The trade-off is the effort of maintaining the schema and keeping it aligned with the code.
Verdict
Use JSON Schema where bad data is costly, such as public APIs, critical pipelines, and config files. A schema only declares the expected fields, types, ranges, and patterns, so a validator has to run it: sample checks during development or CI, and each incoming payload at runtime when the application needs to reject bad requests. A schema alone doesn't turn a runtime error into a build error, and it needs to stay aligned with the code. For internal services with shared TypeScript or Protobuf definitions, that maintenance work may not be worthwhile.
More JSON scenarios
Related guides
Frequently asked questions
Is JSON Schema worth the effort?
What's the minimum schema syntax to validate an email field?
{ "type": "string", "format": "email" } is the usual starting point. In the 2019-09 and 2020-12 drafts, format is an annotation unless the validator enables the format-assertion vocabulary, so implementations can differ. A pattern such as ^\\S+@\\S+\\.\\S+$ is an assertion, but it is only a coarse check and isn't a strict email grammar. Use the schema for a baseline, then apply the application's email policy or a dedicated validator when strict validation matters.How do I validate a nested array of objects in JSON Schema?
items keyword with a child schema. For example: { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "integer" }, "name": { "type": "string" } }, "required": ["id", "name"] } }. This validates every item in the array against the object schema. Add minItems or uniqueItems for further constraints.Related tools
Unix Timestamp
Convert between Unix timestamps and human-readable dates.
Use toolCHMOD Configurator
Calculate Linux file permissions using checkboxes or octal numbers, then view the matching symbolic notation.
Use toolText Encoding Converter
Convert text to Base64, binary, hex, URL encoding and HTML entities, and back again.
Use tool