JSON Input

Generated Schema

What is JSON Schema Generator?

Ever needed to document your API's data structure but didn't want to write a JSON Schema by hand? Paste a sample of your JSON (JavaScript Object Notation) and you get a Draft-07 schema describing its structure: the type of every field (string, integer, number, boolean, null, object, array), nested objects, and which keys are required.

The schema describes the shape of your data, not the exact values. It won't copy "qty": 2 into minimum: 2, maximum: 2, because a schema that only accepts the one document you pasted is no use for validation. For arrays, every element is looked at and merged: if the second line item has a note the first one doesn't, note is in the schema but not required. Integers get "integer", decimals get "number". The output follows the official JSON Schema specification, so it loads in standard validators like Ajv.

It all runs in your browser, so your data never leaves your computer. One sample can only tell the generator so much, though: treat the result as a first draft and add formats, enums and ranges you know about.

How to Use the JSON Schema Generator

Follow these steps to generate a JSON Schema from your JSON data. Each step uses the actual buttons and panels on this page.

1

Paste JSON or Upload File

Paste your JSON into the left JSON Input panel, or click Upload to load a .json or .txt file. Click Sample to see example data. Example input:

{"subscriberId": "SUB-1001", "plan": "Unlimited 5G", "dataUsage": 45.2, "status": "active"}

Works with objects, arrays and plain values. The more representative your sample (several array items, optional fields present in some), the better the schema. Invalid JSON shows an error.

2

View Generated Schema

The right Generated Schema panel updates as you type. It detects types (string, integer, number, boolean, null, object, array), describes nested structures, merges all array items into one item schema, and marks a key required only when every object it was seen in has it. Both panels use syntax highlighting, and the output panel is editable.

3

Copy or Download

Tweak the schema in the right panel if you like, then click Copy to copy it or Download to save it as schema.json. Use it in Swagger/OpenAPI docs or a validation library. Use Clear on the input panel to start over.

When You'd Actually Use This

API Documentation

Got an API response example? Generate a schema from it and use it in your Swagger/OpenAPI docs. Way faster than writing schemas by hand.

Data Validation

Need to validate incoming JSON? Generate a schema from a few real payloads, tighten it where you know more than the sample does (enums, string formats, ranges), and plug it into your validation library.

Type Definitions

Generate schemas to understand data structures. Perfect for documenting complex JSON formats or understanding API contracts.

Contract Testing

Create a baseline schema for contract tests. Because it describes types and required keys rather than exact values, a response with different data but the same shape still passes, and a missing or retyped field fails.

Common Questions

Is my JSON data stored?

Nope. Everything happens right in your browser. Your JSON never leaves your computer – we don't even see it.

What JSON Schema version is used?

We generate schemas that work with JSON Schema Draft 7 and newer. Everything follows the official spec, so it'll work with standard validation tools. Heading into an API spec? Version 3.1 of the OpenAPI Specification builds its schema objects on JSON Schema 2020-12, and a Draft-07 schema like this one usually drops in with little or no editing.

Does it handle arrays?

Yes. Every element of an array is inspected and their schemas are merged into one items schema. Objects with different keys are combined (keys missing from some items become optional), and mixed types become a type list like ["integer", "string"]. An empty array gets items: {}, since there's nothing to infer from.

What about optional vs required fields?

Within an array of objects, a key is required only if every object has it; keys that show up in some items are listed but optional. For a single object, every key in your sample is marked required, because one example can't tell the generator what's optional. Remove keys from required by hand where you know better.

Can I edit the generated schema?

Yes. The output panel is editable, so you can tweak types, add constraints like format or enum, and then copy or download your edited version. Changing the input regenerates the schema and replaces your edits, so finish with the input first.

Does it work with invalid JSON?

No, you'll need valid JSON first. If something's broken, you'll see an error. The JSON Validator points at the problem, and the JSON Fixer can repair common mistakes.

Other JSON Tools You Might Need

Schema generation is just one thing you might need. Here are some other tools that work great together: