F6.1 F6

Seven Types: string, number, integer, boolean, array, object, null

JSON Schema has exactly seven types. Not four, not five — seven. Missing one (especially integer or null) leads to schemas that are either too permissive or too rigid.

The seven types

  • string — text values: "hello", "2024-01-15", "INV-001"
  • number — any numeric value including decimals: 42, 3.14, -17.5
  • integer — whole numbers only: 42, -7, 0. Rejects 3.14
  • boolean — exactly true or false. Nothing else
  • array — ordered lists: [1, 2, 3]. Use items to specify element types
  • object — key-value structures: {"name": "Alice", "age": 30}. Use properties to define fields
  • null — the explicit null value. Not “missing” — present but null

number vs integer: the distinction that matters

number accepts both integers and decimals. integer accepts only whole numbers. If a field represents quantity, count, or age — use integer. If it represents price, percentage, or measurement — use number.

There is no float type. There is no whole_numbers_only flag. The integer type is the whole-number restriction. And using string with regex for numeric validation is unnecessary overhead when native numeric types exist.

null is a real type

A common misconception: null isn’t a JSON Schema type, and you handle absence by omitting the field. Wrong. null is a first-class type. JSON explicitly supports null as a value, and JSON Schema uses it in union types like ["string", "null"] to express nullable fields — the field is present, but its value is null.

This matters for extraction schemas. If a document might not contain a warranty period, you want the model to return {"warranty_period": null} (explicit: “I looked and it’s not there”) rather than fabricating a value to fill a required string field.

Picking the right type

For an invoice extraction schema:

  • invoice_numberstring (text identifier like “INV-2024-001”)
  • total_amountnumber (decimal like 127.50)
  • quantityinteger (whole number like 3)
  • is_paidboolean (true/false)

Using string for everything sacrifices type safety and makes downstream processing harder (parsing “127.50” back into a number). Using number where integer is appropriate allows unwanted decimals. Each field deserves its most specific type.


One-liner: JSON Schema has 7 types — use integer for whole numbers (not number), null for nullable fields (it’s a real type), and always pick the most specific type for each field.