json to json schema converter

typetools

instant, client-side type converter • 0ms network latency

root:
307 chars
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "RootPayload",
  "type": "object",
  "properties": {
    "userId": {
      "type": "string"
    },
    "username": {
      "type": "string"
    },
    "email": {
      "type": "string",
      "format": "email"
    },
    "isActive": {
      "type": "boolean"
    },
    "score": {
      "type": "number"
    },
    "roles": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "metadata": {
      "type": "object",
      "properties": {
        "lastLogin": {
          "type": "string",
          "format": "date-time"
        },
        "ipAddress": {
          "type": "string"
        },
        "failedAttempts": {
          "type": "null"
        }
      },
      "required": [
        "lastLogin",
        "ipAddress"
      ],
      "additionalProperties": false
    },
    "tags": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "integer"
          },
          {
            "type": "null"
          }
        ]
      }
    }
  },
  "required": [
    "userId",
    "username",
    "email",
    "isActive",
    "score",
    "roles",
    "metadata",
    "tags"
  ],
  "additionalProperties": false
}
0.15ms•in-browser
documentation, edge cases & specifications below

step-by-step integration guide

technical specification differences & end-to-end conversion workflow

Establishing Declarative Data Contracts with JSON Schema Draft 2020-12

Raw JSON payloads describe a single instance of data, but they provide no declarative contract for API gateways, OpenAPI 3.1 specifications, or Ajv validation pipelines to verify incoming requests. JSON Schema (standardized in IETF Draft 2020-12 and Draft-07) defines a vocabulary-based meta-schema using keywords like $schema, type, properties, required, items, and additionalProperties. Writing JSON Schema by hand for deeply nested payloads is tedious and error-prone—especially when reconciling optional properties across arrays of objects or specifying string semantic formats like date-time, email, and uuid.

AST Schema Inference, Format Detection, and Required Property Intersection

Our in-browser JSON-to-JSON-Schema generator parses your sample JSON payload into an AST and synthesizes a standards-compliant Draft 2020-12 schema. For every object node, the engine enumerates each key in the properties map and computes the mathematical intersection of keys present across all sampled array elements to populate the required array accurately. Numeric values are differentiated between integer (for whole numbers) and number (for floating-point values). String values are tested against RFC semantic patterns to automatically attach "format": "date-time", "format": "uuid", "format": "email", or "format": "uri" annotations. Nullable fields are emitted using Draft 2020-12 type unions (e.g., "type": ["string", "null"]) or anyOf combinators.

frequently asked questions

common developer questions answered

q:What is the difference between JSON Schema Draft-07 and Draft 2020-12?

Draft 2020-12 aligns fully with OpenAPI 3.1, replaces tuple validation keywords with prefixItems, and standardizes $defs for reusable sub-schemas while maintaining compatibility with modern validators like Ajv v8.

q:How does the generator determine which fields belong in the 'required' array?

When converting an array of objects, only keys that appear in 100% of the array elements are added to the 'required' array; keys missing from any element remain optional.

q:Does the converter detect semantic string formats like email, uuid, and date-time?

Yes. The AST analyzer inspects string literals against RFC 3339 timestamps, RFC 4122 UUIDs, emails, and URIs, automatically adding the appropriate 'format' keyword to the generated property schema.

topic cluster

related type & ast converters

3 interconnected tools