How do I generate JSON Schema from JSON?
Paste sample JSON, choose Draft 2020-12 or Draft-07, click Generate, then copy the schema or switch to TypeScript/Zod/OpenAPI export tabs—all in your browser without upload.
Schema inference runs in your browser from pasted sample JSON—payloads are not uploaded. Default output uses JSON Schema Draft 2020-12; switch to Draft-07 for legacy OpenAPI 3.0 stacks.
Skip to JSON Schema generatorInfer Draft 2020-12 JSON Schema from sample JSON—export TypeScript, Zod, Yup, or OpenAPI snippets and validate payloads locally without upload.
Sample {"name":"John","age":30,"active":true} infers an object schema with string, integer, and boolean properties.
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"name": {
"type": "string",
"minLength": 4,
"maxLength": 4
…Export TypeScript, Zod, Yup, or OpenAPI from the generator below. Validate syntax first with JSON Validator.
Infer schema
Generate Draft 2020-12 / 07 / 06 JSON Schema from sample JSON.
Code exports
Switch output to TypeScript, Zod, Yup, or OpenAPI snippets.
Runs locally
Schema inference runs in your browser—payloads are not uploaded.
All processing stays on your device. Shortcuts: Ctrl/Cmd+Enter generate, Ctrl/Cmd+Shift+C copy, Ctrl/Cmd+Shift+D download.
Options
Formats: email, uri, uuid, date, date-time, ipv4, ipv6, hostname, phone. Patterns: zip, phone, slug, hex color, currency code.
No schema generated yet. Paste JSON or load a sample template.
Inline schema editing
A JSON Schema generator infers a validator-ready schema from a sample JSON payload—walking the object tree to assign types, nested properties, array item shapes, and optional format hints. This tool defaults to Draft 2020-12 and runs entirely in your browser.
JSON Schema is a vocabulary for describing JSON document structure—field types, required keys, nested objects, array items, string formats, and value constraints. Hand-writing schemas for large API responses is slow and error-prone.
This generator takes the opposite approach: paste representative JSON, and the tool walks the tree once to infer `type`, `properties`, `required`, `items`, and optional `format` / `pattern` keywords. Nested objects become nested schema definitions; arrays produce `items` schemas from observed elements; mixed primitive arrays can emit `anyOf` unions.
The shipped UI also exports TypeScript interfaces, Zod schemas, Yup schemas, and OpenAPI component snippets, validates a sample payload against the generated schema, and compares two schema versions in diff mode—all without uploading your JSON.
Use Draft 2020-12 for new projects (Ajv 8+, Pydantic v2, OpenAPI 3.1). Switch to Draft-07 when you must match legacy OpenAPI 3.0 toolchains.
Concise answers for common searches — definitions, steps, and comparisons.
Paste sample JSON, choose Draft 2020-12 or Draft-07, click Generate, then copy the schema or switch to TypeScript/Zod/OpenAPI export tabs—all in your browser without upload.
Yes. Schema inference runs locally in your browser; sample JSON is not uploaded to EverydayTools servers.
Use Draft 2020-12 for new APIs (Ajv 8+, OpenAPI 3.1). Use Draft-07 for legacy OpenAPI 3.0 stacks. This tool supports both plus Draft-06.
Paste a sample object or array—or click a template (User object, nested object, mixed array). Use JSON Validator first if the payload might contain comments or trailing commas.
Select Draft 2020-12 (default), Draft-07, or Draft-06. Toggle required fields, additionalProperties: false, nullable types, enum inference, format/pattern detection, and min/max constraints as needed.
Click Generate or wait for debounced auto-inference. Review the Schema tab, switch to TypeScript or Zod for code exports, or open Tree View for a path-oriented summary.
Paste a test payload in the validation panel to confirm the schema accepts it. Copy formatted or minified output, download schema.json, or refine inline before committing to your repo.
Common real-world scenarios where this tool saves time.
Paste a production API response sample to produce a first-pass schema for OpenAPI components, contract tests, or CI validation with Ajv.
Switch output tabs to TypeScript or Zod after inference—faster than hand-typing interfaces for nested webhook or config payloads.
Generate a schema from a golden fixture, then validate variants in the built-in panel before wiring JSON Schema into API Mock Generator workflows.
Share a schema link with teammates so required fields and nested shapes are explicit—especially after inferring from a real staging response.
Step-by-step chains that connect related tools for common tasks.
Confirm JSON parses, infer a contract, then test payloads before CI.
Bootstrap mock responses that match an inferred contract shape.
Input
{"name": "John", "age": 30, "active": true}Output
type: object with properties name (string), age (integer), active (boolean); $schema: https://json-schema.org/draft/2020-12/schemaA single observed object produces property types from JavaScript typeof checks. Integers stay integer; numbers with decimals become number.
Input
{"email": "john@example.com", "created_at": "2024-01-15T10:00:00Z"}Output
email → type string, format email; created_at → type string, format date-timeWith format detection enabled, common string shapes map to JSON Schema format keywords for validator hints.
Input
{"tags": ["a", "b"], "counts": [1, 2, 3], "mixed": ["x", 1, true, null]}Output
mixed array → items anyOf with string, integer, boolean, and null branchesWhen array elements differ in type, the generator merges item schemas with anyOf (or oneOf/allOf per your setting) instead of forcing a single type.
The engine parses your sample with JSON.parse, then recursively walks each value: booleans → type boolean, integers → integer, floats → number, strings → type string with optional format/pattern detection, arrays → items from merged element schemas, objects → properties map with optional required arrays. Mixed types merge via anyOf/oneOf/allOf. Output is JSON.stringify with 2-space indent plus optional $schema, $id, title, and description headers you provide.
Formula
object → { type: "object", properties: { key: schema(value) }, required?: [...] }
array → { type: "array", items: merge(schema(item)) }
string + regex → { type: "string", format? | pattern? }Choose the draft that matches your validator and OpenAPI version.
| Aspect | Draft 2020-12 (default) | Draft-07 |
|---|---|---|
| $schema URI | https://json-schema.org/draft/2020-12/schema | http://json-schema.org/draft-07/schema# |
| Best for | New APIs, Ajv 8+, OpenAPI 3.1 | OpenAPI 3.0, older validators |
| Tuple arrays | prefixItems supported in spec | items / additionalItems patterns |
| Switching | Select in tool before export | Same inferred tree—change $schema only |
Merge multiple real responses or add placeholder keys before inferring, then tighten required arrays manually.
Match the draft selector to your stack—or change only the $schema URI after export if structures are compatible.
Run JSON Validator first when the source might include comments, trailing commas, or unquoted keys.
Use JSON Validator for JSON.parse syntax errors with line and column feedback.
Import the spec directly—this tool infers from samples, not from Swagger files on disk.
Advertisement
Draft 2020-12 is the default ($schema: https://json-schema.org/draft/2020-12/schema). You can switch to Draft-07 or Draft-06 in the UI for legacy OpenAPI 3.0 or older validator stacks. The inferred property tree is the same; only the $schema URI changes.
Use Draft 2020-12 for new APIs with Ajv 8+, Pydantic v2, or OpenAPI 3.1. Use Draft-07 when your toolchain still expects http://json-schema.org/draft-07/schema#—common with OpenAPI 3.0 and older libraries. Swap the $schema header after export if your validator requires a specific draft.
No. Schema inference, validation, and exports run in JavaScript in your browser. Your payloads—including API keys, tokens, and PII—are not sent to EverydayTools servers during normal use.
Yes. After generating, use the output tabs for TypeScript interfaces, Zod object schemas, Yup shapes, OpenAPI components.schemas snippets, a tree view, or a property summary.
By default required arrays are empty unless you enable Mark all fields required or infer required keys from consistent object keys in arrays. Toggle the option and regenerate—or edit the required array manually before publishing.
JSON Validator checks syntax with JSON.parse only. This tool assumes valid JSON and infers structural contracts—types, nested properties, array items, and optional formats—for schema-aware validation.
No. Inference reflects only what appears in the sample—optional fields absent from the sample will be missing, and rare enum values may be omitted. Review, add descriptions, tighten required arrays, and test edge payloads before production.
Yes. Enable nullable types for null values in the sample. Mixed-type arrays emit anyOf/oneOf/allOf item unions per your union keyword setting.
Yes. Use the Validate sample JSON panel below the schema output to test whether a payload satisfies the current generated schema before copying it to your project.
Yes—free with no signup, no watermark, and no usage limits for browser-based schema inference and export.
Schema inference, inline editing, validation, and exports run on your pasted JSON in the browser without server-side storage of payloads.
Output is inferred from the sample you provide—review required fields, descriptions, and edge cases before production contract use.
For development and documentation—not a substitute for security review or formal API governance.
Advertisement
Reviewed by EverydayTools Editorial Team on 2026-07-08.
Same workflow or intent — pick the next step without leaving the site.
Free JSON formatter — paste minified or messy JSON and instantly get beautified, indented output with syntax highlighting and error detection. Browser-based, no server upload. Runs locally in your browser when supported—no upload required for normal use.
Free JSON path finder — click any value in a formatted JSON tree to instantly copy its JSONPath expression. Ideal for navigating deep API payloads and config files. No signup. Runs locally in your browser when supported—no upload required for normal use.
Free .env file parser — paste any .env file and extract all environment variables as structured JSON or YAML. Useful for config migration and debugging. No signup needed. Runs locally in your browser when supported—no upload required for normal use.
Generate cryptographically secure random API keys in hex, base64, or alphanumeric format — instantly in your browser with no upload, no signup.
Free API mock generator — create realistic mock API responses with custom status codes, response headers, and JSON body. Perfect for frontend development and testing. No signup. Runs locally in your browser when supported—no upload required for normal use.
Free number base converter — convert between binary (base 2), octal (base 8), decimal (base 10), hexadecimal (base 16), and text in real time. No signup required. Runs locally in your browser when supported—no upload required for normal use.
Frequently opened tools from the same category.
Free JSON formatter — paste minified or messy JSON and instantly get beautified, indented output with syntax highlighting and error detection. Browser-based, no server upload. Runs locally in your browser when supported—no upload required for normal use.
Free JSON diff & compare — structural side-by-side diff, ignore paths, array modes, RFC 6902 patch and merge patch export. Runs locally in your browser—no upload.
Free UUID generator: v4, v7 & v1 GUIDs in your browser—bulk up to 1,000, validate, export JSON/CSV. crypto.randomUUID; never uploaded.
Free random number generator — Web Crypto integers or decimals, no-repeat draws, dice, coin flip, and list picker. Copy or CSV. Runs locally in your browser.
Guides and walkthroughs that reference this tool.
Step-by-step guide to calculating your calorie deficit for weight loss using the Mifflin-St Jeor equation and TDEE. Includes BMR formulas, activity multipliers, macro targets, and a free browser-based calorie calculator.
What regex is, how pattern syntax maps to real strings, and where to use it for validation, search-replace, and log parsing—with a quick reference.
Browse full tool collections by topic.