JSON to JSON Schema converter

Turn sample JSON into a JSON Schema: this JSON to JSON Schema generator detects formats like email, date-time and UUID, and merges arrays of objects into one item schema.

JSON

JSON Schema

Waiting for input

What you get

How each result is checked

  1. The generated schema is compiled with Ajv, the most widely used JSON Schema validator.
  2. Your sample is validated against the generated schema. It must pass.

What can't convert exactly

  • A schema inferred from one sample can only describe what the sample shows. Review required fields and enums before relying on it.
  • Turn on "Top-level array = list of samples" to infer one schema from many records.

Questions

Which draft is used?

Draft 2020-12 by default. Draft-07 is available in the options.

Are optional fields detected?

Yes, when you provide several samples: keys that are missing in some records are not required.

How do I generate JSON Schema from JSON?

Paste a sample of your JSON. You get a JSON Schema (2020-12 or draft-07) with types, required fields and formats, and Ajv checks that your JSON validates against it.

Can I generate one schema from multiple samples?

Yes. Paste a JSON array of samples and turn on "Top-level array = list of samples": the schema covers all of them, and fields missing from some samples become optional.

How do I use the generated schema?

Validate data with any JSON Schema library: in JavaScript, compile it with Ajv; in Python, use the jsonschema package. Editors such as VS Code also use it for autocompletion through the "$schema" key or their settings.

How do I convert JSON to JSON Schema online?

Paste your JSON or open a file on the left (or click Example). The JSON Schema appears on the right as you type, already checked. Copy it, or download it as a file. Nothing is uploaded.

Can the JSON Schema output be wrong?

Every result is checked before it is shown (the checks are listed on this page). If a check fails, the page says "Review needed" and why, instead of presenting the output as correct, and anything that cannot convert exactly is named in the notes.