JSON Data
JSON Schema
Validation Result
Pending
About JSON Schema
JSON Schema is a vocabulary for annotating and validating JSON documents. It describes the expected format of JSON data and is used for API validation, configuration file verification, and automated documentation generation.
What is JSON Schema?
- Declarative validation - describe what valid data looks like, not how to check it
- IETF specification - standardized and widely supported across languages
- Composable - schemas can reference and extend other schemas
- Self-documenting - schemas serve as both validation rules and documentation
Core Keywords
| Keyword | Description | Example |
|---|---|---|
type | Restricts the data type | "type": "string" |
properties | Defines expected object properties | "properties": {"name": {"type": "string"}} |
required | Lists properties that must be present | "required": ["name", "email"] |
items | Schema for array elements | "items": {"type": "number"} |
enum | Restricts to a set of values | "enum": ["active", "inactive"] |
const | Restricts to a single value | "const": "v1" |
$ref | References another schema | "$ref": "#/$defs/Address" |
additionalProperties | Controls unlisted properties | "additionalProperties": false |
Type Validation
| Type | Validates | Useful Keywords |
|---|---|---|
string | Text values | minLength, maxLength, pattern, format |
number | Any numeric value | minimum, maximum, multipleOf |
integer | Whole numbers only | minimum, maximum |
boolean | true or false | - |
array | Ordered lists | items, minItems, maxItems, uniqueItems |
object | Key-value pairs | properties, required, additionalProperties |
null | Null value only | - |