Developer Tools
JSON Schema Generator
Generate a JSON Schema (draft 2020-12) from sample JSON — types, nested objects, arrays, required fields and formats like email, date-time and URI.
How to use
- 1Paste a representative JSON sample — arrays with several items give better results.
- 2Copy the schema and refine descriptions, enums and limits by hand.
How it's calculated
Types are inferred from values; objects in an array are merged, and a field is 'required' only if it appears in every sample object.
Frequently asked questions
Which draft is generated?
JSON Schema draft 2020-12, which is supported by modern validators like Ajv and by OpenAPI 3.1.
Why is a field not required?
It was missing from at least one object in an array. Add it to all samples, or edit the 'required' list.
Can it detect enums?
No — a sample can't tell whether a value is one of a fixed set. Add enum lists manually.
Worked example: JSON Schema Generator
Paste an array of two records — [{"id": 1, "email": "[email protected]", "score": 2}, {"id": 2, "email": "[email protected]", "score": 2.5, "note": null}] — and you get a schema typing id as integer, email as a string with format: "email" (detected from the @ and domain pattern), score as number (not integer, because the generator merges both samples and 2.5 forces the wider type), and note as type null. The required array ends up as ["id", "email", "score"] specifically — note is excluded because it's missing from the first record entirely, which is the generator's rule for required: appear in every sample or you're optional.
Why format detection is a double-edged feature
The format toggle recognizes email addresses, ISO date-times, plain dates, URIs and UUIDs purely by regex pattern-matching against the sample strings — it has no idea what the field is actually for. A string that happens to look like 2025-01-01 gets tagged format: "date" even if it's really an invoice number that happens to collide with that pattern. That's fine for genuinely well-formed sample data, but it means you should skim the generated schema for format tags that don't semantically make sense before shipping it, rather than trusting it blindly.
What a sample-based schema can never tell you
The schema only knows what your sample showed it — it can't infer that a status field is really constrained to "active" | "inactive" | "pending" unless your sample happens to include all three, and it can never guess validation rules like string length limits or numeric ranges your API actually enforces. Treat this as a fast first draft of a JSON Schema — the structural skeleton (types, nesting, required-vs-optional) is reliably correct from a representative sample, but enums, descriptions, and min/max constraints still need a human pass before the schema goes into an OpenAPI spec or a validator like Ajv.
An empty box stays empty, and a bad file names the reason
Mark fields required starts on, and detect formats starts on. The sample already in the box has an id, an email, a list of tags, and a timestamp, so the format detection has an email and a date to notice. An empty box produces an empty result, not an error and not a skeleton schema. Invalid JSON stops with the words Invalid JSON and the reason, and I get no schema. A valid document always carries the draft 2020-12 schema address at the top, then the types inferred from what I pasted. The download uses a json name. Turning required off changes whether fields are marked required. It does not stop the types from being inferred.
Related tools
- CSV to SQL INSERT Generator
Generate SQL CREATE TABLE and INSERT statements from CSV data for MySQL, PostgreSQL, SQLite or SQL Server.
- JSON to TypeScript / Go Types
Generate TypeScript interfaces or Go structs from sample JSON — nested objects, arrays and optional fields inferred automatically.
- Nginx Config Generator
Generate an nginx server block for a static site, SPA or reverse proxy — with HTTPS (Let's Encrypt paths), HTTP→HTTPS and www redirects, gzip and caching.
- JSON Formatter & Validator
Format, beautify, validate and minify JSON — with clear line and column error messages and optional key sorting.
- Schema Markup (JSON-LD) Generator
Generate JSON-LD structured data for FAQ pages, articles, products, local businesses and organizations — ready to paste into your page's <head>.
- XML Sitemap Generator
Turn a list of URLs into a valid XML sitemap — with lastmod, change frequency and priority — ready to upload and submit to Google Search Console.