JSON Schema Generator
A JSON Schema generator turns a sample JSON document into a JSON Schema that describes it. Paste JSON (or drop a .json file), pick draft 2020-12 or draft-07, and get types, nested properties, array items, required keys, and common string formats inferred in your tab. Copy or download the schema. Nothing is uploaded.
Updated
This page reads your JSON with the browser's own JSON.parse and walks every value: objects become type object with properties, arrays become type array with one merged items schema, whole numbers become integer and decimals number, and null stays null. When an array holds several objects, their keys are merged — a key that appears in every item is listed in required, a key that appears in only some is kept as optional. A field that is sometimes a string and sometimes null gets type ["string", "null"]. Strings that all look like a date-time, date, email, URL, UUID, or IPv4 address get a format keyword (you can switch that off).
The schema is inferred from the sample you paste, so it can only describe what the sample shows: it does not guess enums, minimum/maximum, string lengths, or patterns, and keys missing from your sample will be missing from the schema. Treat the output as a solid first draft to review, not a contract. This is not an OpenAPI generator, does not fetch a URL, and does not validate data against a schema. Nothing is fetched, uploaded, or written to localStorage.
Paste one JSON sample (object or array). Drop a .json file — it stays in this tab.
Optional .json file. Read with FileReader in this tab — never uploaded.
JSON Schema
Inferred from your sample only — review enums, min/max, patterns, and optional keys before you validate real data. Need to tidy the sample first? Use JSON Formatter.
How does the JSON Schema Generator work?
1. Paste or drop a JSON sample
Paste a JSON object or array, drop a .json file, or press Load example for a small fictional order. Files are read with FileReader in this tab — never uploaded. Invalid JSON shows the parser message with line and column.
2. Pick the draft and options
Choose draft 2020-12 (current) or draft-07 (still common in older validators and editors). Toggle required keys, string-format detection, strict objects (additionalProperties: false), and whether a top-level array should be read as a list of samples of one record.
3. Review the inferred schema
The schema updates as you type. Check optional keys, add enums, min/max, or patterns your sample cannot show, and tighten anything that should be stricter than the sample.
4. Copy or download
Copy the schema or download it as a .schema.json file and drop it into your validator, API contract, or editor config. Closing the tab drops the workspace.
Questions about JSON Schema Generator
- How do I convert JSON to JSON Schema?
- Paste a representative JSON sample into the box above. The generator walks every value and writes a JSON Schema with type, properties, items, and required keys, plus format for strings that look like dates, emails, URLs, UUIDs, or IPv4 addresses. Pick draft 2020-12 or draft-07, then copy or download the result. Everything runs in your browser tab.
- Which JSON Schema draft should I choose — 2020-12 or draft-07?
- Use draft 2020-12 if your validator supports it (for example recent Ajv with its 2020 build, or most current libraries); it is the latest published draft. Choose draft-07 when a tool, editor, or older library only understands draft-07. For the keywords this generator writes — type, properties, required, items, format, additionalProperties — the two drafts mean the same thing, so only the $schema line changes.
- How are required keys decided?
- For a single object, every key in the sample is required. For an array of objects, a key is required only if it appears in every item; keys that appear in some items are kept as optional properties. Turn off Mark keys as required if you would rather add required lists yourself. A key whose value is null is still present, so it still counts as required.
- What happens with mixed types, nulls, and empty arrays?
- If a field is a string in one sample and null in another, the schema uses type ["string", "null"]. Whole numbers are integer; if any sample has a decimal, the field becomes number (integer values still pass). An empty array cannot show its item type, so it gets items: {} — any item allowed — until you give it a sample item or edit it by hand.
- Will it detect enums, minimum and maximum, or string patterns?
- No. A sample cannot tell the generator which values are the only allowed ones or what the limits are, so it does not guess enum, minimum, maximum, minLength, maxLength, or pattern. It only adds format when every string in that field looks like the same format. Add constraints by hand after generating — that is where the schema stops describing the sample and starts describing your rules.
- Can I generate one schema from many JSON examples?
- Yes. Put the examples in a JSON array and tick Top-level array is a list of samples. The generator merges them into one record schema: keys from every example are listed, required is the set present in all of them, and types are widened where examples disagree. Without that option, a top-level array is described as type array with a merged items schema.
- Is this an OpenAPI generator or a JSON Schema validator?
- Neither. It produces a plain JSON Schema document from a JSON sample. You can paste the result into the schema section of an OpenAPI file, but it does not write paths or operations, does not fetch a live API URL, and does not validate JSON against a schema. It is also different from the FAQ schema and schema markup generators on Page Utils, which write schema.org JSON-LD for search engines.
- Does it upload my JSON?
- No. Parsing and inference run with JavaScript in this tab; nothing is sent to Page Utils, nothing is written to localStorage, and closing the tab drops the text — safe for payloads with internal field names. There is one canonical address, /developer/json-schema-generator/, which also covers searches like json to json schema, json schema from json, and generate json schema.
What else can I open?
- JWT Token DecryptDecrypt a compact JWE locally with Web Crypto.
- CSR DecoderDecode PKCS#10 CSRs in the browser — subject, SANs, public key, attributes, and SHA-256 fingerprint.
- Certificate DecoderDecode SSL/X.509 PEM certificates in the browser — expiry, SANs, issuer, fingerprints.
- JSON FormatterTidy, validate, and pretty-print JSON locally.
- JSON MinifyMinify JSON to one line in the browser.
- YAML FormatterFormat and validate YAML in the browser — line/column errors, no upload.
These tools run in your browser. Page Utils does not store, upload, or write to localStorage the keys, tokens, or text you paste. Results are a convenience aid, not legal, tax, or security advice.