Skip to main content
SEO and meta100% FreeInstant

JSON to JSON Schema: Generate a Schema From Sample JSON

This free JSON to JSON Schema tool builds a schema from a sample document. It works out types, nested objects, arrays and required fields, and returns a draft 2020-12 schema that you can copy and refine.

By Debmedia Technologies LLP · Kolkata, India · Updated

What Is JSON to JSON Schema Conversion?

JSON to JSON Schema conversion builds a description of your data’s structure from a sample document. JSON itself only holds values. A JSON Schema describes the rules: which fields exist, what type each one has, which are required and how arrays and nested objects are shaped.

Teams use schemas to validate API requests, document data formats, generate forms and catch bad data early. Writing one by hand for a large document is slow. This JSON to JSON Schema tool creates a first draft from your example in seconds.

How to Use This Tool

  1. Paste a sample of your JSON into the box.
  2. Choose whether strings should be checked for formats such as email, date and URL.
  3. Press Generate schema.
  4. Copy the result with the Copy button and refine it in your editor.

How the Schema Is Built

In your sampleIn the schema
A text valuetype string, with an optional format such as email, uri, date or date-time
A whole numbertype integer
A decimal numbertype number
true or falsetype boolean
An objecttype object, with properties and a required list
An arraytype array, with an items schema merged from all elements
nulltype null

The result uses draft 2020-12, the current version described in the official JSON Schema guide.

How Arrays and Mixed Values Are Handled

  • Arrays of objects. The tool merges every element. A field is marked required only if every element has it.
  • Mixed types. If a field is sometimes a string and sometimes a number, the schema offers both with anyOf.
  • Integers and decimals. A field with both is treated as number.
  • Empty arrays. They give an array with no item rules, because the sample shows nothing.

Improving the Draft

A schema built from one example is only a starting point. Review the required list, because a field that appears in your sample may be optional in real life. Add limits such as minimum, maximum, minLength and enum. Add titles and descriptions to make the schema useful as documentation, and test it against several more samples.

Privacy

The conversion runs in your browser, so sample data, which may contain customer information, is never uploaded.

For search-friendly structured data on web pages, use the FAQ markup generator. To check that a page serves JSON correctly, read its headers with the header viewer, and test the endpoint with the status code checker.

Where Schemas Help

Schemas pay off wherever data crosses a boundary: public APIs, configuration files, message queues and imports. With a schema in place, bad data is rejected at the door with a clear message, instead of causing odd errors much later. Editors and tools can also read a schema to offer auto-completion and inline hints while you write the data.

Frequently Asked Questions

JSON Schema is a vocabulary for describing the shape of JSON data: which fields exist, their types and which are required. Tools use it to validate data and to generate forms and documentation.
A field is marked required if it appears in the sample. For arrays of objects, a field is required only if every item has it.
It is a good first draft built from one example. Review it, add limits such as minimum and maximum, and adjust types that the sample cannot show, such as optional fields.
No. The conversion runs entirely in your browser.

Disclaimer: results come from live requests and can change as records and servers change. We cannot guarantee that every answer matches what every visitor sees.