RunLocalTools

JSON Schema Validator: Check JSON or YAML Against a Schema Online

Validate JSON or YAML against a JSON Schema (draft-04 to 2020-12) with exact line and column errors, batch mode and test cases. Free, runs in your browser.

What it does

Paste or drop a JSON Schema on the left and your data on the right. The validator lists every place the data breaks the schema, with the path, the line and column, the keyword that failed and a plain-English reason, such as “.agemustbe≥18,got12″or”.age must be ≥ 18, got 12″ or “.address is missing the required property ‘city'”. Click an error and the offending text is selected in the data pane.

It reads JSON, JSON with comments and trailing commas, and YAML. It supports drafts 04, 06, 07, 2019-09 and 2020-12, and it also checks the schema itself, with warnings for mistakes such as a misspelled keyword (requried), additionalProperties: false combined with allOf, or a $defs entry nothing uses.

Beyond a single pair of documents, you can validate a whole folder of files at once (batch mode), keep saved test cases that re-run after every schema edit, read an automatic plain-English outline of a schema you did not write, and generate a starter sample from the schema.

How it works

The validation engine is Ajv 8, the same validator used in thousands of Node projects. It is bundled with the tool and runs in your browser, so nothing needs a server.

Ajv reports errors by JSON pointer, not by line number, so the tool uses its own JSON parser that records the exact position of every value and every key. Each error is mapped back to that position: a type error points at the value, an unexpected property points at the key, and a missing required property points at the object that lacks it. The same parser flags duplicate keys (which most validators silently collapse), comments and trailing commas it had to tolerate, and numbers larger than 2^53 that lose precision when read.

The draft is detected from $schema, and you can override it. Optional what-if switches (coerceTypes, useDefaults, removeAdditional) run the validation on a copy of your data and show a diff of what would change; your text is never edited. Cross-file $refs resolve against a local reference store that matches by file name or $id. Batch runs work in short chunks with a progress bar and a cancel button, so the page stays responsive even with thousands of documents.

How to use it

  1. Paste your schema into the Schema pane, or drop a .json or .yaml file on it. “Load example” fills both panes with a sample that has several deliberate errors.
  2. Paste or drop your data into the Data pane. Validation runs as you type.
  3. Read the Results tab. Group errors by path or keyword, filter them, click one to jump to it, or export the list as JSON, Markdown, CSV or text.
  4. If the schema uses $ref to other files, open the Ref store tab and add them. Unresolved references are listed by name.
  5. To check many documents, open the Batch tab, drop files (or a JSON array, or a .jsonl file), and run. Download the valid and invalid sets as separate folders in one zip, plus a CSV report.
  6. Save interesting inputs in the Test cases tab with the result you expect. They re-run after every schema change, with a pass or fail badge.

FAQ

Which JSON Schema drafts are supported?

Draft-04, draft-06, draft-07, 2019-09 and 2020-12. The draft is picked from the $schema keyword. If there is none, the tool assumes 2020-12 and tells you so. You can force a draft in the options, and the tool warns when your choice and the schema’s own $schema disagree.

Why does additionalProperties: false reject properties I declared in allOf?

In drafts up to 2019-09, additionalProperties only looks at the properties declared next to it. Anything declared inside allOf, anyOf, oneOf or a $ref counts as “additional”. The fix in 2019-09 and 2020-12 is unevaluatedProperties: false, which understands those combinations. The schema checker flags this pattern and suggests the fix.

Can I validate YAML?

Yes. Set Input format to YAML, or leave it on Auto. YAML is read into the plain JSON data model (strings, numbers, booleans, null, lists and maps), and dates stay strings. Errors in YAML data are shown with their path, but without a line and column, because exact positions are only tracked for JSON.

Why is a number flagged as losing precision?

JavaScript stores numbers as 64-bit floats, so integers above 9,007,199,254,740,991 cannot be represented exactly. The tool warns when your data contains one, because checks like multipleOf or maximum may then give a wrong answer. If you need exact large integers, store them as strings.

Can it fetch a schema or $ref from a URL?

Only if you tick a clearly labelled box. It is off by default, and while it is off the fetch code cannot run. When it is on, the tool requests the URL you give it, with no cookies and no referrer, and nothing else leaves your browser. Many servers refuse cross-origin requests; if yours does, download the file and add it to the Ref store instead.

How many documents can the batch mode handle?

It is limited by your browser’s memory, not by a server. A thousand small documents validate in a fraction of a second, and larger runs show progress and can be cancelled. Files above 25 MB are not saved for the next visit, and the tool tells you when that happens.

Privacy

Validation, YAML parsing, linting, batch runs and everything else described above are local. The validation engine is a single file served with the tool, so your schema and data are never sent anywhere.

One feature optionally uses the internet: fetching a schema or $ref from a URL. It is off by default, sits behind its own checkbox, resets to off every time you open the tool, and sends only a plain request to the address you type.

To survive a refresh, your schema, data, reference files, batch files and test cases are saved in your browser’s own storage on this device. They are never uploaded. A “Remember my data” checkbox turns off the saving of your data, test cases and batch files and deletes their stored copies, and “Clear saved work” removes everything.

Limitations

  • Format checks cover the common formats (email, uri, date, date-time, time, duration, uuid, ipv4, ipv6, hostname, regex, json-pointer and a few more). Unknown formats are reported and not checked.
  • Remote $refs are not resolved unless you add the files yourself or use the optional URL fetch.
  • Line and column positions are available for JSON; YAML errors show the path only.
  • The sample generator is best-effort and says so: it builds a minimal valid document from required fields and types, and it tells you when the sample does not fully pass.
  • Schemas are compiled with the browser’s built-in code generation. A page that forbids unsafe-eval in its Content-Security-Policy will block it, and the tool shows a clear message if that happens.
  • Very large files are limited by your browser’s memory.
  • If your data will not parse, clean up the syntax with the JSON formatter first.
  • Schemas written in YAML can be checked and tidied with the YAML validator and formatter.
  • To see exactly what the what-if options changed, or to compare two versions of a document, use JSON diff.
  • Once the data validates, JSON to TypeScript can turn the same shape into an interface.