toolbench.online

Converters

JSON Schema Generator

Generate JSON Schema from example JSON using Draft 2020-12 or Draft 7. Inspect inferred types and configure required or optional fields.

JSON Schema Generator

Generate JSON Schema from example JSON using Draft 2020-12 or Draft 7. Inspect inferred types and configure required or optional fields.

Ready to run. Input limit: 1 MB characters.

Output

—

Output actions

Ready to copy output once your result appears.

JSON Schema Generator mini guide

Generate JSON Schema from example JSON using Draft 2020-12 or Draft 7. Inspect inferred types and configure required or optional fields.

How to use JSON Schema Generator

  1. 1Paste representative example JSON, or choose Load sample.
  2. 2Choose Schema draft and decide whether to Make all fields optional.
  3. 3Select Convert, inspect the generated definitions, then copy or download them.

What it is good for

  • • Create a Draft 2020-12 schema starting point.
  • • Compare inferred types across array examples.
  • • Generate optional-field schemas for partial records.

Example

Input

{"name":"Alice","age":30}

Output

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "name": {"type":"string"},
    "age": {"type":"integer"}
  },
  "required": ["name","age"]
}

Rules and limitations

The draft selector produces an explicit $schema URI for Draft 2020-12 or Draft 7. Objects infer properties and a required list; arrays infer a shared items schema. Mixed types use anyOf instead of assuming every item has the first item’s shape.

Required fields are those present in every supplied object at the same inferred location. Make all fields optional clears required lists. Empty arrays provide no item evidence, so their items schema permits any type. Null remains a distinct type.

Inference describes the sample, not your complete domain model. A single example cannot establish permitted enums, string formats, length limits or future variants. Supply diverse array samples and review the result against your API contract before relying on it.

Common problems

Valid JSON uses double quotes and excludes comments and trailing commas. A sample containing only an empty object or empty array cannot imply a useful detailed shape.

Generated schemas intentionally omit additionalProperties restrictions, bounds, patterns and formats. Add these constraints only when your domain rules establish them.

Frequently asked questions

Does this infer nested objects?

Yes. Nested shapes are inferred recursively.

Are missing sample fields optional?

Yes for object variants within arrays; fields absent from any corresponding sample are optional.

Can an example define the full contract?

No. Examples cannot prove all permitted values, formats or required business rules.

What happens to empty arrays?

Items have an unknown type in TypeScript or an unconstrained schema until you supply examples.

Is my input uploaded or saved?

This tool processes input in your browser and does not save its input or output to local storage. Copy and download are user actions. The site uses analytics for page and action metadata and may use ads and production error reporting; see the Privacy Policy for those services.

About this tool

Maintained by Toolbench. For large or deeply nested files, split the input into smaller batches and verify representative results before using them in an import or application. Report reproducible problems through Contact.

Continue with a practical guide

Convert nested JSON to CSV without losing fields

Choose between flattened columns and JSON cells, preserve arrays and review missing values before exporting.

Related tools

Continue the workflow with nearby tools for formatting, publishing, debugging, or follow-up checks.

JSON to TypeScript

Generate nested TypeScript interfaces from example JSON. Name the root interface, infer array unions and choose optional fields.

JSON Formatter

Format or minify JSON with configurable indentation.

JSON Compare Online

Compare two JSON blobs with structural diff.

JSON to CSV

Convert a JSON array of objects to CSV.