JSON Schema Generator

Infer a JSON Schema from a sample document

How to generate a JSON Schema

  1. Paste one or more representative JSON samples. If you paste an array, all items are merged.
  2. Give the schema a title using the root name field.
  3. A draft 2020-12 schema is produced with type, properties, items and required for every level.
  4. Copy or download it and refine it by hand: add format, enum, minimum, pattern or description where you need stricter rules.

What a schema is for

A JSON Schema describes the expected shape of JSON data. It lets you validate API requests and responses, configuration files and form submissions; generate documentation; power editor autocompletion (VS Code reads schemas for JSON and YAML); and describe structured output and tool parameters for LLM APIs.

Inference rules: a key is listed in required only if it appears in every object of the sample, integers are typed integer while decimals are number, values that are sometimes null get a type array such as ["string", "null"], and empty arrays get an unrestricted items. The output is a starting point; a generator cannot know business rules such as allowed values or maximum lengths.

Generation is done locally in your browser.

FAQ

Which JSON Schema version is used?

Draft 2020-12, the current version, declared in the $schema field. It is supported by Ajv, jsonschema for Python and most modern validators.

Can I use the schema for OpenAI or Claude tool definitions?

Yes, the property definitions can be used as tool parameters. You may need to remove $schema and title, and add descriptions to help the model.

How do I make a field optional?

Remove its name from the required array of its parent object.

Made by BufferMint. We also design and build software products for founders. See our services →

Your files and inputs never leave your device; we only count anonymous visits.