For the complete documentation index, see llms.txt. This page is also available as Markdown.

Overview

How Internet Object schemas describe the shape of data, and the pieces that make them up.

An Internet Object schema describes the shape of the objects in a document: their members, the type of each value, and the constraints each value must satisfy. A schema is written in the same object syntax as the data it validates, so it is compact, readable, and easy to author by hand.

Schema and data share one syntax. Unlike map-based schema languages (JSON Schema, XML Schema), an IO schema looks like the object it validates. There is no second grammar to learn.

A schema is normally declared once in the header — as the default $schema or as a reusable $ reference — and applied to every record in the data section. Validating a value against a schema either succeeds or produces a stable error code.

The shape of an object

A schema is a comma-separated list of members. In its simplest form it is just a list of keys; each value then has the any type:

name, age, address
---
John, 30, { Main St, NYC }

Give a member a type by writing key: type:

name: string, age: int, isActive: bool
---
John, 30, T

Add constraints by replacing the bare type with a MemberDef — a small object whose first value is the type and whose remaining entries are constraints:

score: { int, min: 0, max: 100 }
---
85

A value outside the constraint fails validation with a stable code:

score: { int, min: 0, max: 100 }
---
150          # ✗ mismatched-max — score is above max

Members nest: a member's type can itself be an object schema or an array:

The building blocks

A schema is assembled from a few orthogonal pieces. Each has its own reference page:

Piece
What it does
Reference

MemberDef

One member: a type plus its constraints

Data types

The base types and built-in shortcuts (string, int, email, …)

TypeDef

The fixed set of options each type accepts

Optional, nullable & defaults

?, *, and default values

Open & dynamic schemas

Allowing extra members with * and *: type

References

Reusable schemas and types ($name)

Union types

A value matching one of several types (anyOf)

Composition & reuse

Building large schemas from small ones

The exact placement rules — open vs. closed objects, keyed vs. positional members, and how the default $schema is chosen — are covered in Schema Representation.

Optional, nullable, and default members

A member name can carry a marker that changes how a missing or null value is treated. These markers are first-class schema features, not informal conventions: a conformant validator MUST honor them.

  • Optional (?) — the member MAY be omitted from the data.

  • Nullable (*) — the member MAY be null (N).

  • Both (?*) — the member may be omitted or null.

  • Default — the second value in a MemberDef supplies a value to use when the member is omitted (equivalently, the keyed default: option).

See MemberDef for the full resolution rules and Open & Dynamic Schemas for accepting members beyond those listed.

Schema grammar

The shape of a member, informally:

The complete, normative grammar for documents and schemas is in the Formal Grammar appendix.

A complete example

A header defines a reusable $address and a default $schema; the data section is validated against it:

Both records validate: John Doe supplies an address; Jane Doe omits the optional address.

See Also

Last updated

Was this helpful?