Docs / Schemas / document-extraction
Document Extraction 0.8.0
Represent the layout and content of a document, including text blocks, geometric coordinates, and page structure.
$idhttps:// oatschema.org/ 0.8.0/ document-extraction - Latest
https:// oatschema.org/ document-extraction - Versions
- Source
- v0.8.0 on GitHub
Schema
{ "x-license": { "id": "Apache-2.0", "notice": "Copyright 2025-2026 The OATS Authors", "url": "https://github.com/oatschema/oats/blob/main/LICENSE" }, "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://oatschema.org/0.8.0/document-extraction", "title": "Document Extraction", "x-version": "0.8.0", "description": "Represent the layout and content of a document, including text blocks, geometric coordinates, and page structure.", "type": "object", "properties": { "extraction_type": { "type": "string", "description": "Optionally indicate the extraction type.", "enum": [ "text", "lines", "boxes", "polygons", "mixed" ] }, "producer": { "type": "string", "description": "The creator (model, tool or author) of this extraction.", "maxLength": 1024 }, "unit": { "type": "string", "description": "The unit for all coordinate values: 'px' for pixels, 'pt' for typographic points, 'normalized' for values from 0.0 to 1.0, and 'per_mille' for values from 0 to 1000. Required whenever geometric data is present.", "enum": [ "px", "pt", "normalized", "per_mille" ] }, "page_width": { "description": "The width of the page(s), in the record's unit if 'px' or 'pt', otherwise in any unit shared with page_height. Can be a single number for uniform documents, or an array of objects mapping specific widths to page numbers.", "oneOf": [ { "type": "number", "title": "Uniform Width", "exclusiveMinimum": 0 }, { "type": "array", "title": "Variable Widths", "minItems": 1, "maxItems": 10000, "items": { "type": "object", "description": "A width shared by one or more pages.", "properties": { "value": { "type": "number", "description": "The width of these pages.", "exclusiveMinimum": 0 }, "pages": { "type": "array", "description": "The page numbers (1-indexed) that share this width.", "minItems": 1, "maxItems": 100000, "uniqueItems": true, "items": { "type": "integer", "minimum": 1 } } }, "required": [ "value", "pages" ], "additionalProperties": false } } ] }, "page_height": { "description": "The height of the page(s), in the record's unit if 'px' or 'pt', otherwise in any unit shared with page_width. Can be a single number for uniform documents, or an array of objects mapping specific heights to page numbers.", "oneOf": [ { "type": "number", "title": "Uniform Height", "exclusiveMinimum": 0 }, { "type": "array", "title": "Variable Heights", "minItems": 1, "maxItems": 10000, "items": { "type": "object", "description": "A height shared by one or more pages.", "properties": { "value": { "type": "number", "description": "The height of these pages.", "exclusiveMinimum": 0 }, "pages": { "type": "array", "description": "The page numbers (1-indexed) that share this height.", "minItems": 1, "maxItems": 100000, "uniqueItems": true, "items": { "type": "integer", "minimum": 1 } } }, "required": [ "value", "pages" ], "additionalProperties": false } } ] }, "score_explanation": { "type": "string", "description": "Defines the meaning of the 'score' field.", "maxLength": 256 }, "blocks": { "type": "array", "description": "An array of text blocks extracted from the document.", "maxItems": 100000, "items": { "type": "object", "description": "A single extracted block of text or geometry.", "properties": { "block_type": { "type": "string", "description": "Defines the nature of this specific block (text, line, box, polygon, or multi_polygon).", "enum": [ "text", "line", "box", "polygon", "multi_polygon" ] }, "id": { "type": "string", "description": "A unique identifier (e.g., UUID4) for this block, useful for referencing.", "maxLength": 128 }, "text": { "type": "string", "description": "The text content of the block. Required for text and line block types.", "maxLength": 4096 }, "line_number": { "type": "integer", "description": "The line number of the block within its page, if applicable.", "minimum": 1 }, "page_number": { "type": "integer", "description": "The page number (1-indexed) where this block is located.", "minimum": 1 }, "score": { "type": "number", "description": "The confidence score for this block's detection and transcription, ranging from 0.0 (uncertain) to 1.0 (certain).", "minimum": 0, "maximum": 1 }, "box": { "type": "object", "description": "A rectangular bounding box defined by its top-left corner (x, y) and its dimensions.", "properties": { "x": { "type": "number", "description": "The x-coordinate of the top-left corner.", "minimum": 0 }, "y": { "type": "number", "description": "The y-coordinate of the top-left corner.", "minimum": 0 }, "width": { "type": "number", "description": "The width of the box.", "minimum": 0 }, "height": { "type": "number", "description": "The height of the box.", "minimum": 0 } }, "required": [ "x", "y", "width", "height" ], "additionalProperties": false }, "polygon": { "type": "array", "description": "An ordered list of vertices defining a non-rectangular boundary.", "minItems": 3, "maxItems": 1000, "items": { "type": "object", "description": "A single vertex, measured from the top-left corner of the page or image.", "properties": { "x": { "type": "number", "description": "The x-coordinate of the vertex.", "minimum": 0 }, "y": { "type": "number", "description": "The y-coordinate of the vertex.", "minimum": 0 } }, "required": [ "x", "y" ], "additionalProperties": false } }, "multi_polygon": { "type": "array", "description": "A list of polygons, for a single region that is occluded or fragmented into multiple visible parts.", "minItems": 1, "maxItems": 100, "items": { "type": "array", "description": "An ordered list of vertices defining a non-rectangular boundary.", "minItems": 3, "maxItems": 1000, "items": { "type": "object", "description": "A single vertex, measured from the top-left corner of the page or image.", "properties": { "x": { "type": "number", "description": "The x-coordinate of the vertex.", "minimum": 0 }, "y": { "type": "number", "description": "The y-coordinate of the vertex.", "minimum": 0 } }, "required": [ "x", "y" ], "additionalProperties": false } } }, "attributes": { "type": "object", "description": "Arbitrary metadata relevant to this block.", "maxProperties": 16, "propertyNames": { "maxLength": 128 }, "additionalProperties": { "anyOf": [ { "type": "string", "maxLength": 1024 }, { "type": "number" }, { "type": "boolean" }, { "type": "null" } ] } } }, "required": [ "block_type" ], "allOf": [ { "if": { "properties": { "block_type": { "enum": [ "text", "line" ] } } }, "then": { "required": [ "text" ] } }, { "if": { "properties": { "block_type": { "const": "box" } } }, "then": { "required": [ "box" ] } }, { "if": { "properties": { "block_type": { "const": "polygon" } } }, "then": { "required": [ "polygon" ] } }, { "if": { "properties": { "block_type": { "const": "multi_polygon" } } }, "then": { "required": [ "multi_polygon" ] } }, { "if": { "properties": { "block_type": { "const": "line" } } }, "then": { "anyOf": [ { "required": [ "box" ] }, { "required": [ "polygon" ] }, { "required": [ "multi_polygon" ] } ] } } ], "additionalProperties": false } }, "attributes": { "type": "object", "description": "Arbitrary metadata relevant to this extraction.", "maxProperties": 16, "propertyNames": { "maxLength": 128 }, "additionalProperties": { "anyOf": [ { "type": "string", "maxLength": 1024 }, { "type": "number" }, { "type": "boolean" }, { "type": "null" } ] } } }, "required": [ "blocks" ], "allOf": [ { "if": { "properties": { "blocks": { "contains": { "anyOf": [ { "required": [ "box" ] }, { "required": [ "polygon" ] }, { "required": [ "multi_polygon" ] } ] } } }, "required": [ "blocks" ] }, "then": { "required": [ "unit" ] } }, { "if": { "properties": { "unit": { "const": "normalized" } }, "required": [ "unit" ] }, "then": { "properties": { "blocks": { "items": { "properties": { "box": { "properties": { "x": { "maximum": 1 }, "y": { "maximum": 1 }, "width": { "maximum": 1 }, "height": { "maximum": 1 } } }, "polygon": { "items": { "properties": { "x": { "maximum": 1 }, "y": { "maximum": 1 } } } }, "multi_polygon": { "items": { "items": { "properties": { "x": { "maximum": 1 }, "y": { "maximum": 1 } } } } } } } } } } }, { "if": { "properties": { "unit": { "const": "per_mille" } }, "required": [ "unit" ] }, "then": { "properties": { "blocks": { "items": { "properties": { "box": { "properties": { "x": { "maximum": 1000 }, "y": { "maximum": 1000 }, "width": { "maximum": 1000 }, "height": { "maximum": 1000 } } }, "polygon": { "items": { "properties": { "x": { "maximum": 1000 }, "y": { "maximum": 1000 } } } }, "multi_polygon": { "items": { "items": { "properties": { "x": { "maximum": 1000 }, "y": { "maximum": 1000 } } } } } } } } } } } ], "additionalProperties": false}
Examples
Records that pass validation against this schema.
document-extraction-2
{ "extraction_type": "mixed", "unit": "px", "page_width": [ { "value": 850, "pages": [1] }, { "value": 1100, "pages": [2] } ], "page_height": 1100, "blocks": [ { "block_type": "box", "id": "logo-box", "page_number": 1, "box": { "x": 50, "y": 50, "width": 200, "height": 80 }, "attributes": { "visual_class": "logo" } }, { "block_type": "multi_polygon", "id": "occluded-stamp", "page_number": 2, "multi_polygon": [ [ {"x": 100, "y": 100}, {"x": 200, "y": 100}, {"x": 200, "y": 150}, {"x": 100, "y": 150} ], [ {"x": 100, "y": 180}, {"x": 200, "y": 180}, {"x": 200, "y": 250}, {"x": 100, "y": 250} ] ] } ]}
document-extraction-1
{ "extraction_type": "mixed", "unit": "pt", "blocks": [ { "block_type": "text", "id": "c7a4b0c8-3b1a-4b6f-8c3b-2a7e1a3e4b5c", "text": "Annual Report Summary", "page_number": 1 }, { "block_type": "box", "id": "d8b5c1d9-4c2b-4c7f-9d4c-3b8f2b4f5c6d", "text": "The first column of text begins here, discussing the quarterly earnings and projections for the upcoming fiscal year.", "page_number": 1, "box": { "x": 50, "y": 120, "width": 250, "height": 400 } }, { "block_type": "box", "id": "e9c6d2e0-5d3c-4d8b-a0e5-4c9c3c5c6d7e", "text": "The second column contains shareholder information and a summary of the annual general meeting.", "page_number": 1, "box": { "x": 320, "y": 120, "width": 250, "height": 400 } }, { "block_type": "polygon", "id": "f0d7e3f1-6e4d-4e9a-b1f6-5d0b4d6b7e8f", "text": "This caption is wrapped around a circular diagram on the page.", "page_number": 2, "polygon": [ { "x": 100, "y": 100 }, { "x": 500, "y": 100 }, { "x": 500, "y": 250 }, { "x": 350, "y": 250 }, { "x": 350, "y": 150 }, { "x": 100, "y": 150 } ] } ]}
Fields
-
extraction_typestringOptionally indicate the extraction type.
Allowed values:
"text","lines","boxes","polygons","mixed" -
producerstringThe creator (model, tool or author) of this extraction.
- at most 1024 characters
-
unitstringThe unit for all coordinate values: 'px' for pixels, 'pt' for typographic points, 'normalized' for values from 0.0 to 1.0, and 'per_mille' for values from 0 to 1000. Required whenever geometric data is present.
Allowed values:
"px","pt","normalized","per_mille" -
page_widthnumber | array of objectThe width of the page(s), in the record's unit if 'px' or 'pt', otherwise in any unit shared with page_height. Can be a single number for uniform documents, or an array of objects mapping specific widths to page numbers.
Exactly one of these forms:
-
Uniform Width number
- > 0
-
Variable Widths array of object
Each item: A width shared by one or more pages.
- 1 to 10000 items
-
valuenumber requiredThe width of these pages.
- > 0
-
pagesarray of integer requiredThe page numbers (1-indexed) that share this width.
- 1 to 100000 items
- items must be unique
- each ≥ 1
-
-
page_heightnumber | array of objectThe height of the page(s), in the record's unit if 'px' or 'pt', otherwise in any unit shared with page_width. Can be a single number for uniform documents, or an array of objects mapping specific heights to page numbers.
Exactly one of these forms:
-
Uniform Height number
- > 0
-
Variable Heights array of object
Each item: A height shared by one or more pages.
- 1 to 10000 items
-
valuenumber requiredThe height of these pages.
- > 0
-
pagesarray of integer requiredThe page numbers (1-indexed) that share this height.
- 1 to 100000 items
- items must be unique
- each ≥ 1
-
-
score_explanationstringDefines the meaning of the 'score' field.
- at most 256 characters
-
blocksarray of object requiredAn array of text blocks extracted from the document.
Each item: A single extracted block of text or geometry.
- at most 100000 items
-
block_typestring requiredDefines the nature of this specific block (text, line, box, polygon, or multi_polygon).
Allowed values:
"text","line","box","polygon","multi_polygon" -
idstringA unique identifier (e.g., UUID4) for this block, useful for referencing.
- at most 128 characters
-
textstringThe text content of the block. Required for text and line block types.
- at most 4096 characters
-
line_numberintegerThe line number of the block within its page, if applicable.
- ≥ 1
-
page_numberintegerThe page number (1-indexed) where this block is located.
- ≥ 1
-
scorenumberThe confidence score for this block's detection and transcription, ranging from 0.0 (uncertain) to 1.0 (certain).
- 0 to 1
-
boxobjectA rectangular bounding box defined by its top-left corner (x, y) and its dimensions.
-
xnumber requiredThe x-coordinate of the top-left corner.
- ≥ 0
-
ynumber requiredThe y-coordinate of the top-left corner.
- ≥ 0
-
widthnumber requiredThe width of the box.
- ≥ 0
-
heightnumber requiredThe height of the box.
- ≥ 0
-
-
polygonarray of objectAn ordered list of vertices defining a non-rectangular boundary.
Each item: A single vertex, measured from the top-left corner of the page or image.
- 3 to 1000 items
-
xnumber requiredThe x-coordinate of the vertex.
- ≥ 0
-
ynumber requiredThe y-coordinate of the vertex.
- ≥ 0
-
multi_polygonarray of array of objectA list of polygons, for a single region that is occluded or fragmented into multiple visible parts.
Each item: An ordered list of vertices defining a non-rectangular boundary.
- 1 to 100 items
- each 3 to 1000 items
-
xnumber requiredThe x-coordinate of the vertex.
- ≥ 0
-
ynumber requiredThe y-coordinate of the vertex.
- ≥ 0
-
attributesobjectArbitrary metadata relevant to this block.
- at most 16 properties
- keys at most 128 characters
-
*string | number | boolean | nullAny other key.
- string: at most 1024 characters
Rules:
-
When the condition below holds,
textis required.Show the JSON Schema
{ "if": { "properties": { "block_type": { "enum": [ "text", "line" ] } } }, "then": { "required": [ "text" ] }} -
When
block_typeis"box",boxis required.Show the JSON Schema
{ "if": { "properties": { "block_type": { "const": "box" } } }, "then": { "required": [ "box" ] }} -
When
block_typeis"polygon",polygonis required.Show the JSON Schema
{ "if": { "properties": { "block_type": { "const": "polygon" } } }, "then": { "required": [ "polygon" ] }} -
When
block_typeis"multi_polygon",multi_polygonis required.Show the JSON Schema
{ "if": { "properties": { "block_type": { "const": "multi_polygon" } } }, "then": { "required": [ "multi_polygon" ] }} -
When
block_typeis"line": at least one ofbox,polygon,multi_polygonmust be present.Show the JSON Schema
{ "if": { "properties": { "block_type": { "const": "line" } } }, "then": { "anyOf": [ { "required": [ "box" ] }, { "required": [ "polygon" ] }, { "required": [ "multi_polygon" ] } ] }}
-
attributesobjectArbitrary metadata relevant to this extraction.
- at most 16 properties
- keys at most 128 characters
-
*string | number | boolean | nullAny other key.
- string: at most 1024 characters
Rules:
-
When the condition below holds,
unitis required.Show the JSON Schema
{ "if": { "properties": { "blocks": { "contains": { "anyOf": [ { "required": [ "box" ] }, { "required": [ "polygon" ] }, { "required": [ "multi_polygon" ] } ] } } }, "required": [ "blocks" ] }, "then": { "required": [ "unit" ] }} -
When
unitis"normalized", further limits apply.Show the JSON Schema
{ "if": { "properties": { "unit": { "const": "normalized" } }, "required": [ "unit" ] }, "then": { "properties": { "blocks": { "items": { "properties": { "box": { "properties": { "x": { "maximum": 1 }, "y": { "maximum": 1 }, "width": { "maximum": 1 }, "height": { "maximum": 1 } } }, "polygon": { "items": { "properties": { "x": { "maximum": 1 }, "y": { "maximum": 1 } } } }, "multi_polygon": { "items": { "items": { "properties": { "x": { "maximum": 1 }, "y": { "maximum": 1 } } } } } } } } } }} -
When
unitis"per_mille", further limits apply.Show the JSON Schema
{ "if": { "properties": { "unit": { "const": "per_mille" } }, "required": [ "unit" ] }, "then": { "properties": { "blocks": { "items": { "properties": { "box": { "properties": { "x": { "maximum": 1000 }, "y": { "maximum": 1000 }, "width": { "maximum": 1000 }, "height": { "maximum": 1000 } } }, "polygon": { "items": { "properties": { "x": { "maximum": 1000 }, "y": { "maximum": 1000 } } } }, "multi_polygon": { "items": { "items": { "properties": { "x": { "maximum": 1000 }, "y": { "maximum": 1000 } } } } } } } } } }}
Copyright 2025-2026 The OATS Authors. Licensed under Apache-2.0.