Data / LOCAL TOOL

JSON to JSON Schema

Infer a Draft 2020-12 JSON Schema from representative JSON without uploading it.

Runs locally — input is never uploaded
Paste or drop a JSON sample
Ready when you are

WHAT IT DOES

A schema for what the sample shows, with no invented certainty.

Drop or paste representative JSON and get a JSON Schema using the 2020-12 dialect. Object properties, required keys, arrays, numeric kinds, nullability, and mixed sample values are inferred from the document. Objects remain open because one response cannot prove that another property is forbidden, and empty arrays receive an unconstrained item schema because no element type was observed. The result is a reviewable starting contract rather than a claim that one example described every future value.

Why use it?

Use a sample to start a validation contract when writing every property by hand would be repetitive. Inference records observations, not the complete business rules.

How to use this tool

  1. Paste representative JSON and infer the schema.
  2. Review required properties and item types. For example, if only one of two records contains a nickname, that property should not become required.
  3. Add rules that samples cannot establish, such as allowed values, bounds, or whether extra properties are forbidden.
  4. Test the edited contract in JSON Schema Validator with both acceptable and deliberately invalid documents.

Details and limitations

  • The generated document declares the official Draft 2020-12 meta-schema and uses anyOf when the sample demonstrates more than one value kind.
  • Multiple objects inside an array are merged, with only the keys present in every observed object included in required.
  • additionalProperties is deliberately omitted, which leaves objects open until a human who knows the contract chooses to close them.

WORKED EXAMPLES

An empty list cannot establish its item type

Infer a schema from a response whose items array has no observations. Then add an item object and infer again to compare the evidence.

Response

{"items":[]}

Expected result

items is an array with an unconstrained item schema, not an invented string or object type. The object remains open to additional properties until you deliberately restrict it.

COMMON QUESTIONS

JSON → Schema questions

Why does the schema allow properties that were not in my sample?
A sample can demonstrate that a property exists, but it cannot demonstrate that no other property is valid. The generator therefore leaves objects open instead of adding additionalProperties false without evidence.
What happens with an empty array?
Its items schema is left unconstrained. With no elements to inspect there is no defensible way to choose string, object, number, or another type.