Skip to main content
Quicktype infers JSON Schema from sample JSON data. It works well when you have example outputs but no model or schema definition yet. Quicktype currently emits draft-06 JSON Schema. That reflects the tool’s output format, not a recommendation to target draft-06 in new hand-written schemas.

Install

npm install -g quicktype

Basic usage

Given a sample JSON file:
{
  "name": "Alice Johnson",
  "email": "alice@acme.com",
  "role": "Product Manager"
}
Quicktype infers types from the values it sees and wraps everything in a $ref + definitions structure. The type name (Sample) is derived from the filename. Unlike Genson, Quicktype sets additionalProperties: false by default.

Multiple samples

Pass multiple samples to improve inference. Quicktype merges them and detects optional fields: a field missing from some samples becomes non-required:
{"name": "Alice", "email": "alice@acme.com", "phone": "+1-555-0100"}
phone is correctly detected as optional since it only appears in one sample. When multiple source files are provided, the type is named TopLevel instead of being derived from a filename.

Nested objects

Quicktype extracts nested objects into separate definitions and references them via $ref:
{
  "name": "Alice",
  "address": {
    "street": "123 Main St",
    "city": "Springfield",
    "country": "US"
  }
}
The key name address is PascalCased to Address for the definition.

Arrays

Quicktype infers item types from array contents:
{
  "question": "What is your favorite color?",
  "options": ["red", "green", "blue"],
  "tags": ["survey", "color"]
}
Quicktype does not add minItems or maxItems; add those manually. See Bounded Arrays.

Arrays of objects

When arrays contain objects, Quicktype extracts the item schema into a separate definition, singularizing the field name:
{
  "contacts": [
    {"name": "Alice", "email": "alice@acme.com"},
    {"name": "Bob", "email": "bob@acme.com"}
  ]
}
The field contacts produces a definition named Contact (singular).

Type inference across samples

When multiple samples expose different field sets, Quicktype correctly distinguishes required from optional and infers integer vs number:
{"id": 1, "label": "first"}
id (whole numbers) is typed as integer while score (decimal) is typed as number. score is optional since it only appears in one sample.

Limitations

Quicktype infers structure and types but does not add semantic constraints. The generated schema will not include:
  • enum values
  • minLength, maxLength, or pattern for strings
  • minItems, maxItems for arrays
  • description on fields or the schema
It also uses draft-06 and wraps every type in $ref + definitions rather than the more modern $defs. The output is a starting point. Tighten it by adding constraints manually or follow Improve your schema.