Start free

JSON Schema

JSON Schema is a vocabulary for describing the shape of a JSON document, used to declare which fields you expect and what type each one should be (string, number, boolean, array, or object).


JSON Schema is a standard, language-neutral way to describe the structure of JSON data. It lets you state, up front, which keys a document should contain and what type each value must be. You can also mark fields as required, allow optional ones, and nest objects and arrays to describe more complex records.

In web extraction, a schema flips the usual workflow. Instead of telling a scraper where each value sits in the page with selectors, you describe the data you want and let the extraction step map the page onto it. This is far more durable, because your schema describes meaning, not markup positions that change when a site is redesigned.

Extracto uses your JSON Schema as a strict contract. The page is rendered, an LLM fills your fields at temperature zero, and the result is validated against the schema before it is returned. Anything that does not match is rejected, and missing fields come back as null rather than a guessed value, so you never receive data that contradicts what you asked for.

Examples

A product schema

A schema with title as a string, price as a number, and inStock as a boolean tells Extracto exactly what to return and how each value should be typed, with no ambiguity about the output shape.

Catching bad data

If a price comes back as the string '19.99' instead of a number, schema validation rejects it, so a malformed value never reaches your database or your downstream code.

See also

JSON Schema: FAQ

Is JSON Schema the same as a TypeScript type?
They overlap in spirit but not in form. Both describe shape, but JSON Schema is language-neutral and is validated at runtime against actual data, while a TypeScript type is checked at compile time and erased before your code runs.
Do I need to learn JSON Schema to use Extracto?
No. You describe the fields you want in a simple object and Extracto handles validation. Knowing the basics helps you express optional fields and nested structures, but the common cases are very simple and easy to write by hand.

Want to put this into practice? Extracto extracts structured data from a URL using a JSON schema, with the result validated before it leaves the API. Try the live demo or read the docs.