Developer Utilities · Free tool
JSON Schema Generator
Create a draft-07 schema with types and required fields from any JSON instantly in your browser—free tool with no sign-up or download.
Advertisement
What it does
JSON Schema is the de facto standard for describing the structure and constraints of JSON data. Where JSON itself is just a data format, JSON Schema specifies what valid JSON looks like — required fields, allowed types, value ranges, string patterns, array length limits, nested-object structures. It's used to validate API request and response bodies, generate forms from schemas, document configuration files, drive code-generation in dozens of languages, and underlie OpenAPI / Swagger specifications. Modern API tooling (Stripe, GitHub, AWS, OpenAI all expose OpenAPI definitions which embed JSON Schema) depends on it.
Writing JSON Schema by hand from scratch is tedious — for a complex API response with 30 fields, you're looking at hundreds of lines of schema. The generator inverts the problem: paste a sample JSON document, and it infers the schema automatically. Type inference walks the structure: strings stay string, numbers become number, booleans boolean, arrays infer their item type from the first element (or use “oneOf” if items vary), objects recursively become schema definitions. Required fields are inferred from what's present in your sample. The output is a draft-07 (or 2019-09 / 2020-12) JSON Schema ready to paste into your validation library.
Caveats: inference from a single sample isn't perfect. The generator can't know which fields are optional (it sees all-present in your sample, marks all required), can't infer format-specific constraints (email pattern, date format, UUID), can't infer enum values from a single string sample. So treat the generated schema as a STARTING POINT — you'll need to manually mark optional fields, add format hints (“ format: email”, “format: date-time ”), define enums where applicable, set minimum/maximum constraints, and add descriptions for documentation. The generator saves you 70-80% of the typing; the remaining 20-30% is judgment calls only you know.
Embed this tool on your siteShow snippetHide
Paste this snippet into any page. Loads on-demand (lazy), no tracking scripts, and sized to most dashboards. Replace the height to fit your layout.
<iframe src="https://freetoolarena.com/embed/json-schema-generator" width="100%" height="720" frameborder="0" loading="lazy" title="JSON Schema Generator" style="border:1px solid #e2e8f0;border-radius:12px;max-width:720px;"></iframe>How to use it
- Paste a sample JSON document representative of your data shape.
- Click Generate — schema is inferred from the structure.
- Review the output: types, required fields, nested object shapes.
- Edit manually: mark fields optional (remove from required[]), add format hints, set enums, add descriptions.
- Copy the schema and use it with a validator (Ajv for JS, jsonschema for Python, etc.).
When to use this tool
- Bootstrapping a JSON Schema for a new API endpoint from a sample response.
- Documenting an existing API where you have data but no formal schema.
- Generating OpenAPI definitions — copy schemas into the components/schemas section.
- Driving form generation — many JSON-Schema-based form tools (RJSF, json-editor) use schemas to render UIs.
- Validating LLM JSON outputs — use the schema in a validator to enforce structure.
When not to use it
- When you have multiple sample variants — feeding only one may misinfer required vs optional. Combine multiple samples or use a tool that handles arrays of samples.
- When format-specific validation matters (email, URL, UUID, date) — generator can’t infer these; you must add format hints manually.
- For TypeScript types directly — use a JSON-to-TS converter; TypeScript types are not the same as JSON Schema.
- For schema design — a real schema involves business logic (constraints, references, conditionals) that can’t be inferred from data alone.
Common use cases
- Pre-decision sanity-check on inputs and outputs
- Educational use — demonstrating the underlying concept
- Onboarding a colleague who needs the same calculation/conversion
- Verifying a number or output before passing it on
Frequently asked questions
- Which JSON Schema draft should I use?
- Draft-07 is the most widely-supported in tooling; safe default. Draft 2019-09 added unevaluatedProperties / unevaluatedItems and improved $ref behavior; Draft 2020-12 split into vocabularies for modularity and is the latest. Most validators support 07 by default and 2019-09 / 2020-12 with explicit version specification. Pick based on your toolchain.
- How do I make fields optional?
- Edit the generated schema manually. The generator infers all present fields as required; for optional fields, remove them from the required array. Or use additionalProperties (allow extra unknown fields) and a more permissive structure if your API has many optional fields.
- Can I generate schema for variant array items?
- If your sample array has mixed item types (some strings, some objects), the generator typically infers union types via oneOf or anyOf. Review carefully — sometimes the schema becomes overly permissive. Better approach: design the schema explicitly using oneOf with separate schemas for each variant.
- How do I add format hints (email, URL, UUID)?
- Manually edit. After generating the base schema, change `"type": "string"` for an email field to `"type": "string", "format": "email"`. JSON Schema defines several built-in formats (email, uri, uuid, date, time, date-time, ipv4, ipv6, hostname). Most validators check these formats out of the box. Custom formats require validator-specific setup.
- What's the difference between properties and patternProperties?
- properties define exact-name fields (firstName, age). patternProperties define dynamic-name fields matching a regex (e.g., any field starting with “user_”). Use properties for known fixed schema; patternProperties for maps/dictionaries with predictable key patterns. Both are valid; pick based on your data shape.
- Can I include $ref to other schemas?
- Generator typically inlines everything. For shared sub-schemas (e.g., Address used in multiple places), manually refactor to use $ref pointing to /definitions/Address (draft-07) or /$defs/Address (2019-09+). Refactoring after generation is normal — generators give you a starting structure; reuse comes from manual cleanup.
Advertisement
Learn more
Guides about this topic
- Developers & Technical · GuideHow to write JSON schemasValidate any data structure by writing clear JSON Schemas. Learn core keywords and composition for free with an instant online guide; no sign-up or download is needed.
- Using Our Tools · GuideHow to generate QR codesMake QR codes for URLs, WiFi, vCard, or text. Learn error correction and sizing, then generate your QR code online free with no sign-up in seconds.
- Using Our Tools · GuideHow to create a strong passwordGenerate a strong password instantly online for free. Build high-entropy passphrases following NIST 2026 rules with no download needed.
- Developers & Technical · GuideHow to encode and decode Base64Understand the 3-to-4 mechanic and 33% overhead for standard, URL-safe, and MIME Base64. Free online reference to avoid common mistakes, no download needed.
- Design & Media · GuideHow to choose a color paletteBuild accessible color palettes using HSL theory, monochromatic to triadic schemes, WCAG contrast checks, and dark mode tips. Free, no-download guide.
- Developers & Technical · GuideHow to use JWT tokens securelyImplement secure JWT authentication by choosing RS256, setting expiration, using httpOnly cookies, and preventing 'alg: none' attacks in your browser for free.
Explore more developer utilities tools
- Port Number LookupSearch over 140 well-known TCP and UDP ports by number or service name. Free online reference tool with no sign-up, covering web, mail, DNS, and more.
- Test Credit Card NumbersReference table of canonical test card numbers from Stripe, Adyen, and Braintree sandbox docs. Plus Luhn validator + network detector.
- IPv6 Expander & ShortenerFormat IPv6 addresses to canonical form, handling zone IDs and prefixes, instantly online—free tool with no registration required.
- Htpasswd GeneratorCreate .htpasswd lines for Apache or nginx basic auth with browser-only SHA hashing instantly. Includes config snippets and a free online tool with no registration.
- Chmod CalculatorCalculate Unix file permissions: octal (755, 644) ↔ symbolic (rwxr-xr-x) ↔ rwx checkboxes. Covers setuid, setgid, sticky bit. With presets.
- Excel Formula ExplainerPaste any formula and get a plain-English breakdown of 60+ functions online free—no sign-up required, in your browser.