PrettifyPrettify

JSON Schema Validator

Check a JSON document against a JSON Schema and see every error at once, each with its path and line. Schema validation runs in the Prettify editor, in your browser. The box below checks that your JSON parses; the schema check is the next step in the editor.

Result
The result of the check shows here as you paste.
Runs in your browser. Nothing is uploaded.

What the validator does

A JSON Schema describes the shape your data must have: which keys are required, which types they hold, and which values are allowed. Validation checks a document against that description.

Prettify validates a JSON or YAML document against a schema you choose. It lists every error, not only the first, in the Problems panel. Each error names the path, the line, and the rule that failed.

JSON Schema validation is a Pro feature. Free users get one free try per day. The box at the top of this page checks JSON syntax only. It does not read a schema.

Key features

You can attach a schema in four ways. Once one is attached, the toolbar button shows its name, and a schema bar offers a Clear button that removes it. The tool is available for JSON and YAML documents.

  • Paste: paste a schema document. Prettify names it from its title, or Custom schema when it has none.
  • URL: enter the address of a schema file and fetch it.
  • Presets: pick one of eight schemas. They are package.json, tsconfig.json, ESLint, Prettier, GitHub Actions, GitHub Issue Template, Babel, and JSON Schema Draft-07.
  • Auto-detect: if no schema is attached and the document is an object with a $schema property that holds an http URL, Prettify fetches that schema. The schema bar labels it Auto-detected.
  • Prettify validates again as you edit, so the Problems panel updates while you fix the document.
  • The engine is Ajv 8 with the ajv-formats package, so standard formats such as email, uri, and date-time work. Strict mode is off, so real-world schemas with union types validate.

How to use it

Check the syntax first, then attach a schema in the editor. The box above runs in your browser and takes documents up to 512 KB. Larger documents go straight to the editor, which handles big files.

  1. Paste your JSON into the box at the top of this page, or select Try an example.
  2. Read the result. A valid document shows Valid JSON and its shape. An error shows its line and column.
  3. Select Open in full editor. The button reads Fix it in the editor when the JSON has an error.
  4. In the editor, click JSON Schema in the toolbar, under the Check group.
  5. Choose the Paste, URL, or Presets tab, then apply a schema with Validate & Apply, Fetch & Apply, or a preset name.
  6. Read the Problems panel. It opens on its own when an error appears.
  7. Fix the errors in the Raw view. The list updates as you edit.

Worked example

This schema requires name and version, allows no other keys than the four it lists, and sets types for port and contact. The document below breaks four of those rules.

Prettify reports all four in one pass. The two errors at the root, shown as a slash, are about the whole object, so they point to line 1.

Schema
{
  "type": "object",
  "required": ["name", "version"],
  "additionalProperties": false,
  "properties": {
    "name": { "type": "string", "minLength": 1 },
    "version": { "type": "string" },
    "port": { "type": "integer", "minimum": 1, "maximum": 65535 },
    "contact": { "type": "string", "format": "email" }
  }
}

Document
{
  "name": "my-app",
  "port": "8080",
  "contact": "not-an-email",
  "debug": true
}

Problems
line 1  /: must have required property "version"
line 1  /: has unknown property "debug"
line 3  /port: must be integer
line 4  /contact: must match format "email"

Reading the errors

Each message starts with the path to the failing value. Here, port holds the string "8080" where the schema wants an integer. To fix it, write 8080 without quotes.

Add the version key, remove debug, and correct the email address. The Problems list then empties, and the document passes.

Common use cases

Schema validation catches mistakes that a syntax check cannot, because the JSON is valid but the data is wrong. These are the common jobs for it, from config review to schema design.

  • Check package.json, tsconfig.json, or a GitHub Actions workflow against its published schema with a preset.
  • Validate an API payload against the JSON Schema your API contract publishes.
  • Test a new schema against sample documents while you write it, and use the Draft-07 preset to check the schema itself.
  • Confirm that a config file has its required keys before it reaches CI.
  • Find which field in a large payload holds the wrong type.

Limits to know about

Prettify supports JSON Schema draft-07. A schema that names another draft in $schema, such as 2020-12, can fail to compile. A $ref that points to another URL is not fetched, and fails the same way. In both cases Prettify shows a warning that starts with Schema validation failed.

Prettify finds each error line by searching your text for the keys on the path. Treat the line as a close pointer and use the path to be sure. Very large or high-precision numbers are checked on a rounded copy, so numeric rules on them are best effort.

Frequently asked questions

Is the JSON Schema validator free?

Not fully. JSON Schema validation is a Pro feature in Prettify, and free users get one free try per day. Pro is US$19.99, paid once, with lifetime access and no subscription.

Which JSON Schema drafts are supported?

Draft-07. Prettify uses Ajv 8 in its default setup. A schema that names another draft in $schema, such as 2020-12, can fail to compile, and you then see a warning instead of results.

Can I validate YAML against a JSON Schema?

Yes. The JSON Schema tool works on JSON and YAML documents. The presets include GitHub Actions, whose workflow files are YAML. Other formats do not offer the tool.

Is my JSON uploaded when I validate it?

No. Validation runs in your browser. Prettify makes a network request only to fetch a schema from a preset, a URL, or a $schema address. That request does not send your document.

What happens if the schema cannot be fetched?

A failed URL or preset fetch shows an error with the reason. If an auto-detected $schema cannot be fetched, Prettify tells you once that validation was skipped.

Related tools