KeXtract

JSON Schema

A JSON schema defines a formal contract for your data. Designing a clear schema aligned with the domain reduces misunderstandings; recognising its constraints (performance, rigidity) prevents surprises in production.

JSON Schema

A JSON Schema is a standard used to formally describe the structure of a JSON document. It allows you to define which fields are present, which are required, the type of data they must contain (strings, numbers, arrays, objects), and the constraints they must satisfy, such as minimum values, specific formats or maximum lengths.
Before writing a schema, consider the following questions:

  • Which fields are mandatory for my workflow?
  • Which values must be numeric, dates or enums?
  • Are there any repetitions or hierarchies (arrays of objects, nested structures) to model?

These decisions will guide your choices regarding required fields, types, formats, enums, and object/array structures.


How to create a good schema:

Be descriptive and specific

Clear names (e.g. routing_number instead of number) and descriptions help the model correctly interpret your data. Add a description for each field.

Use correct types

Use numeric types for amounts. If a field represents a date, define it as a string with an appropriate format (e.g. YYYY-MM-DD). Avoid extracting numerical values as strings if you need to perform calculations later.

Fallback and normalisation

Provide optional fields where appropriate. Use regex to validate common formats. Use enums for fields with predefined values.

Refine the input

Ensure the input documents are clean and well-structured to optimise token usage and improve comprehension by the LLM.


Request a trial account (which allows you to work with approximately 100 pages) and build your schema in the playground.

Limitations and Risks


Analyse the responses and refine your schema.

Do you have any questions? Write to us at info@kextract.it