99tools

JSON Schema Generator & Validator

runs in your browser

Build a JSON Schema from a sample document, or check JSON against a schema and see every problem with the exact path that failed.

Mode
Draft

JSON sample

Schema

about this tool

Two directions

Generate infers a JSON Schema from a sample document: it walks the data, works out the type of every field, and produces a schema describing it. That turns a five-minute job into a five-second one when you need a schema for an API you did not design.

Validate goes the other way: give it a schema and a document, and it reports every place the document fails, with the path to the offending value and a readable explanation instead of a raw error object.

Validation uses Ajv, the standard JavaScript validator, so a result here matches what your server-side validation will say. It is loaded on demand, which is why this tool is badged as loading a library.

If what you want from a sample is types in a programming language rather than a schema, JSON to TypeScript & Types infers those from the same input.

Drafts

Both 2020-12 and draft-07 are supported. Draft-07 remains the safest choice for interoperability — plenty of tooling never moved past it — while 2020-12 is the current specification and what to pick for something new. If a schema is rejected by another tool, a draft mismatch is the first thing to check.

What generation can and cannot know

An inferred schema is a description of the example you gave it, not of your domain. From one document a generator cannot tell:

  • which fields are genuinely required and which merely happened to be present
  • whether an empty array holds strings or objects
  • that a string is really an enum, a date, an email or a UUID
  • that a number has a meaningful minimum, or that a field is nullable

So treat the output as a first draft. The usual next steps are trimming required to the fields that truly are, adding format where a string has one, and replacing a loose string with an enum where the values are fixed. Generating from several representative samples rather than one exposes the optional fields quickly.

Reading a validation failure

Errors are reported at a readable path, so /users/2/email tells you which element of which array is wrong. Ajv reports every failure it finds rather than stopping at the first, which means fixing a document is one pass instead of several.

A schema mismatch inside anyOf or oneOf produces several errors at once by design: the validator cannot know which branch you intended, so it reports why each one failed.

Privacy

Generation and validation both run in the browser, so you can point this at a production payload without sending it anywhere.

If what you need is a realistic sample to generate the schema from, the fake data generator produces one that is safe to publish.

OpenAPI describes request and response bodies with JSON Schema (3.1 exactly, 2.0 and 3.0 with a close variant), so an API document is often where a schema comes from; the OpenAPI viewer reads one and shows every named schema it defines, with references inside the document followed.

questions

Can I generate a JSON Schema from an example document?
Yes. Paste a sample and a schema is inferred from it. Treat the result as a first draft: it describes the example, not your domain, so required fields and enums will need adjusting by hand.
Why is every field marked as required in the generated schema?
Because a generator can only see that the fields were present in the sample you gave it. Generate from several representative documents to reveal which fields are genuinely optional, then trim the required list.
Which JSON Schema drafts are supported?
2020-12 and draft-07. Draft-07 is the safer choice for interoperability since much tooling never moved past it; 2020-12 is the current specification. A draft mismatch is the first thing to check when another tool rejects a schema.
Will validation results match my server?
It uses Ajv, the standard JavaScript validator, so results line up with what Ajv-based server validation reports. Every failure is listed rather than stopping at the first, so fixing a document takes one pass.
Why do I get several errors for one field?
Because the field sits inside an anyOf or oneOf. The validator cannot know which branch you intended, so it reports why each one failed.