JSON to JSON Schema Generator Online

Generate a JSON Schema (Draft 2020-12 or Draft 7) from any JSON sample — type, properties, required, nested objects, and array items. 100% in your browser.

What is a JSON to JSON Schema generator?

A JSON to JSON Schema generator reads a JSON sample and emits a JSON Schema document — a portable, language-agnostic contract that any validator (Ajv, Pydantic, opis, networknt) can use to enforce shape and types at runtime. The output is plain JSON itself, with $schema, type, properties, required, and items driving validation.

Hand-writing a JSON Schema for a 50-field API response is tedious — every property needs a type entry, every nested object an inner schema, every array an items definition. OpenFormatter walks the JSON tree once, infers types, marks observed keys as required, and produces a Draft 2020-12 schema that you can drop into your API spec, contract test suite, or runtime validator.

How to generate JSON Schema from JSON — 4 steps

  1. Paste a representative JSON sample. Include all fields you expect — anything missing will not appear in required or properties.
  2. Click Generate. The tool emits a Draft 2020-12 schema with $schema, $id, title, and the full property tree.
  3. Tweak required and add formats. Remove optional fields from required, add format: "date-time" on ISO strings, set minLength or pattern where useful.
  4. Wire into a validator. Compile with Ajv in Node, jsonschema in Python, or networknt in Java. Use it on every API request body for runtime safety.

JSON to JSON Schema example

Sample JSON

{
  "id": 42,
  "name": "Ada Lovelace",
  "active": true,
  "tags": ["admin", "engineer"]
}

Generated JSON Schema

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://example.com/schema.json",
  "title": "Root",
  "type": "object",
  "properties": {
    "id": { "type": "integer" },
    "name": { "type": "string" },
    "active": { "type": "boolean" },
    "tags": {
      "type": "array",
      "items": { "type": "string" }
    }
  },
  "required": ["id", "name", "active", "tags"]
}

Draft 2020-12

Latest stable JSON Schema spec with $schema and $id pre-filled. Swap to Draft 7 by changing the $schema URI for OpenAPI 3.0 compatibility.

Nested + arrays

Nested objects become inline schemas, arrays get items inferred from the first element. Refactor common shapes into $defs by hand.

Client-Side Only

JSON is parsed in JavaScript inside the browser. Internal API responses, tokens, or PII never reach a server.

Common use cases

  • check_circleBootstrapping a JSON Schema for an OpenAPI 3.1 components/schemas section
  • check_circleGenerating contract tests that validate API responses match their documented shape
  • check_circleProducing a runtime validator with Ajv to reject malformed request bodies in Express, Fastify, or Hapi
  • check_circleDriving form validation in a JSON-Schema-aware UI library (react-jsonschema-form, uniforms)
  • check_circleValidating Kafka or RabbitMQ event payloads against an evolving schema registry
  • check_circleGenerating language-specific types downstream with quicktype or json-schema-to-typescript
  • check_circleDocumenting third-party webhook payloads (Stripe, GitHub, Shopify) with a versioned schema
  • check_circleValidating configuration files (config.json, tsconfig.json) at startup using jsonschema

Why client-side generation matters

The JSON you paste often contains real customer data, OAuth tokens, signed URLs, or internal field names you do not want indexed by a third-party converter. OpenFormatter generates the schema entirely in JavaScript on your device — open the Network tab in DevTools and you will see zero requests when you click Generate. Safe for enterprise use, safe behind a corporate proxy, safe when the API contract is itself confidential.

Need other JSON tooling?

Validate, format, or convert JSON to language-specific types — all browser-side.

Frequently Asked Questions

What is JSON Schema Draft 2020-12?

JSON Schema Draft 2020-12 is the latest stable specification of JSON Schema, defined by the JSON Schema specification working group. It introduces $dynamicRef, $dynamicAnchor, prefixItems for tuple validation, and improvements to vocabularies. Most modern validators (Ajv 8+, Pydantic v2, opis/json-schema) support it. The generator emits 2020-12 by default — change the $schema URI to draft-07 if you target an older validator.

How are required fields detected?

The generator marks every key present in the sample object as required, on the assumption that fields you observed in a real payload are part of the contract. If a field is optional in your API, remove it from the required array after generating. For optional fields, also consider adding nullable: true (Draft 7) or "type": ["string", "null"] (Draft 2020-12).

Can I generate Draft 7 instead?

Yes — change the $schema value to "http://json-schema.org/draft-07/schema#". Draft 7 is widely used by OpenAPI 3.0 and many existing tools, though OpenAPI 3.1 fully supports 2020-12. The generated structure (type/properties/required/items) is identical between the two drafts for the cases produced here, so swapping $schema is enough.

How does this differ from a TypeScript or Java type generator?

A type generator produces source code in a language. A JSON Schema generator produces a portable validation contract that any language can consume — Ajv in JavaScript, Pydantic in Python, opis/json-schema in PHP, JSON-Schema-Validator in Java. Use the schema as the source of truth and generate language-specific types from it (quicktype, json-schema-to-typescript) for full interoperability.

How are nested objects represented?

Each nested object becomes an inline object schema with its own type, properties, and required arrays. For deduplication, refactor identical nested shapes into $defs and reference them with $ref. The generator does not deduplicate automatically — that requires structural diffing across paths.

How are arrays handled?

A JSON array becomes "type": "array" with an items schema inferred from the first element. If the array is empty, items is left as {} (no constraint). For tuple validation (positional items of different types), switch to prefixItems in Draft 2020-12.

Is the JSON uploaded to your servers?

No. Conversion runs entirely in your browser via JavaScript. Open DevTools → Network and click Convert — no requests are made. Even production payloads with PII or tokens never leave your machine.

How do I validate JSON against the generated schema?

In JavaScript: install Ajv (npm i ajv), then const ajv = new Ajv(); const validate = ajv.compile(schema); validate(data). In Python: pip install jsonschema, then jsonschema.validate(data, schema). In Java: networknt/json-schema-validator. Each library returns errors with paths, perfect for API request body validation.

JSON to JSON Schema Generator Online — Draft 2020-12