YamlBox

JSON tools

JSON to JSON Schema Generator

Paste a sample payload and get a ready-to-use JSON Schema that documents it and validates future data. Array items are merged sensibly, and required fields are detected automatically.

Options

Sample JSON

Examples: API payload · Array of records — ⌘/Ctrl + Enter converts · drop a file to load it · processed locally

JSON Schema

Output is read-only. Use Copy, Download or Share to move it out.

How to use the json to json schema tool

  1. Paste a representative sample

    The richer the sample, the better the schema — include optional fields, nulls and at least two array items so their shapes can be merged.

  2. Pick the draft

    Draft-07 is supported by almost every validator and editor; 2020-12 is the current specification. Choose per your toolchain.

  3. Use the schema

    Paste it into AJV, Prisma, an OpenAPI components block, or your editor’s schema settings for instant validation and autocomplete.

What makes this one different

  • Merges array items into a single schema with common required fields
  • Correct integer vs number detection
  • Optional title, draft-07 or 2020-12 output
  • Nested objects and arrays inferred recursively, to any depth
  • No data leaves the browser — safe for real customer payloads

Privacy by architecture: this page contains no analytics that receive your input, and the conversion code runs in your tab. You can disconnect from the network after loading and keep working.

JSON to JSON Schema — frequently asked questions

How accurate is inferred JSON Schema?

Types and structure are accurate for the sample you provide. What inference cannot know is business rules — that an age must be positive, or that a field is an enum. Treat the output as a strong starting point and add constraints by hand.

How are arrays with different item shapes handled?

Item schemas are merged: properties present in every item become required, and properties present in only some items stay optional. Type differences produce a union such as type: ["string", "number"].

Should I choose draft-07 or 2020-12?

Choose draft-07 if your validator is AJV 6/7, older editors, or anything not updated recently — it has the widest support and is what most OpenAPI 3.0 tooling expects. Choose 2020-12 for new projects and AJV 8.

Where can I use the generated schema?

AJV and other validators for runtime checks, VS Code for autocomplete and validation of your JSON files, OpenAPI specs to document API responses, and CI pipelines to fail builds when a response drifts from the contract.

Searching for “infer json schema”, “generate json schema from json”, “json schema generator online”? You are in the right place — browse all 19 tools.

Deeper reading

Blog · 6 min read JSON to JSON Schema: from sample payload to contract Convert JSON to JSON Schema in the browser: infer a draft from a real payload, then harden required fields, formats and enums — plus the limits of inference. Read the guide →