Logo JSON Parser Online

Generate JSON Schema from Sample Data

Paste a JSON sample and click Generate Schema. The tool inspects every property and nested object, infers types, and produces a JSON Schema draft-07 definition. Use it as a starting point for API documentation, data validation, or code generation.

All JSON Tools

28 tools

Free, fast, runs in your browser. No login needed.

Made with ❤️ in India · © 2025 parsejsononline.com
INPUT
1
OUTPUT
1
✅ Ready
Characters: 0
Ctrl+Enter to run
What is this tool?

How to use

  1. Paste your JSON sample into the INPUT pane.
  2. Click Generate Schema.
  3. The output is a valid JSON Schema draft-07 document.
  4. Copy or download the schema, then adjust it to match your production requirements.

How it works

The generator walks your JSON recursively. For each value it encounters, it infers the JSON Schema type: string, number, boolean, null, object, or array. Object properties are listed under properties, and all discovered keys are added to required.

What gets generated automatically:

  • Type inference for all primitive fields
  • Nested object schemas with their own properties
  • Array schemas with items derived from the first element
  • The $schema declaration pointing to draft-07

What you will need to add manually:

  • Optional fields — every key from your sample appears in required. Remove keys that are optional in production.
  • Validation constraints — minLength, maxLength, pattern, minimum, maximum, enum values are not inferred from a single sample.
  • Union types — a field that can hold a string or null in different records will only reflect the type of the sample value. Add anyOf manually.
  • Array item diversity — only the first array element is used to infer the items schema. Mixed-type arrays need manual adjustment.

The output is a valid starting point, not a production-ready schema. Treat it as scaffolding and review it against the full range of data your system produces.

FAQ

What version of JSON Schema does this produce?

JSON Schema draft-07, indicated by the $schema field in the output. Draft-07 is widely supported by validators like ajv and is compatible with most OpenAPI 3.0 tooling.

Are all fields required by default?

Yes. Every key found in your sample appears in the required array. This is correct if your sample is representative of the minimum viable document. If some fields are optional in production, remove them from required manually.

Does it handle nested objects and arrays?

Yes. Nested objects produce their own properties and required blocks recursively. Arrays produce an items schema derived from the first element in the array.

Why is my number field typed as "number" instead of "integer"?

The generator uses JavaScript's typeof, which returns "number" for both integers and floats. If your field only holds integers, change the type to "integer" manually.

Does this use an external schema library?

No. The schema generator is a custom recursive function built into the tool. It does not use quicktype, ajv, or any external library.

Can I use the output to validate JSON?

Yes, but review it first. Paste the schema into a validator like ajv or use it in an OpenAPI spec. Since required includes all keys and there are no format/pattern constraints, validation will be permissive until you refine the schema.

Related tools

JSON ValidatorValidate syntax before generating a schema. Mock JSON GeneratorGenerate mock data from a sample structure. JSON to TypeScriptGenerate TypeScript interfaces from the same sample.