Docs / Editing tools
JSON Schema validation
Last updated:
JSON Schema validation checks a JSON or YAML document against a JSON Schema and reports every error with its line. JSON Schema validation is a Pro feature in Prettify. Free users get one try per day.
Open JSON Schema validation
Load a JSON or YAML document, then open the tool.
- Load JSON or YAML in the editor.
- Click JSON Schema in the toolbar, under the Check group.
The tool is available for JSON and YAML only. Once a schema is attached, the toolbar button shows the schema name.
Choose a schema
The dialog has three tabs. It opens on Paste.
- Paste: paste a JSON Schema document and apply it.
- URL: enter the address of a JSON Schema file and fetch it.
- Presets: pick a common schema from the list. Prettify fetches it from SchemaStore.org, except JSON Schema Draft-07, which comes from json-schema.org.
The presets cover these schemas.
| Preset | Use |
|---|---|
| package.json | npm package manifest |
| tsconfig.json | TypeScript configuration |
| ESLint (.eslintrc) | ESLint configuration |
| Prettier (.prettierrc) | Prettier configuration |
| GitHub Actions | workflow files |
| GitHub Issue Template | issue template config |
| Babel (.babelrc) | Babel configuration |
| JSON Schema Draft-07 | a schema that validates schemas |
Auto-detected schemas
If the document is an object with a $schema property that holds an http URL, Prettify fetches that schema and validates against it. The schema bar labels this source as auto-detected. If the schema cannot be fetched, Prettify tells you once that validation was skipped.
How errors show
Prettify validates as you edit and lists every error in the Problems panel. The panel opens on its own when an error appears. Each error names the path, the line, and the rule that failed, for example a missing required property or an unknown property.
{
"name": "my-app"
}
A schema that requires version reports: /: must have required property "version". The part before the colon is the path of the value that failed. / is the whole document, and /scripts/test is the test key inside scripts.
Validation engine
Prettify validates with Ajv 8 and supports JSON Schema draft-07. It reports all errors at once, not just the first. It runs with Ajv strict mode off, so real-world schemas that use union types validate without extra setup. The ajv-formats package adds standard formats, such as email, uri, and date-time.
Very large or high-precision numbers are validated on a coerced copy, so a numeric check on a preserved big integer is best-effort.
Related
Try it online
Tool pages for this topic. Each one runs in your browser.