docs2json

Every field in a json file, with its type and meaning.

Every file converts to one JSON document with the same three parts: schema, metadata and content. Each field below has a fixed path, type and meaning.

Download the JSON Schema to validate files or generate types in your own code.

docs2json

One document converted to structured JSON. Three parts: schema names the format and its version, metadata describes the file and where each value came from, and content holds the pages and every element on them in reading order. Every field has a fixed path and meaning, so it can be mapped into another schema without walking a tree or resolving a pointer.

FieldTypeDescription
schemaschemaInfo
metadatametadata
contentcontent

schema

Which format this file is, and which version of it.

FieldTypeDescription
namestringAlways docs2json.One of docs2json
versionstringFormat version, major.minor. The minor number goes up when a field is added and existing mappings keep working. The major number goes up when a change breaks a mapping.

metadata

Facts about the document, grouped by where each value comes from.

FieldTypeDescription
filefile
propertiesoptionalproperties
statsstats
processingprocessing
extractedoptionalarray of extractedFactFacts a language model read from the document's first and last pages, named in the document's own vocabulary (an invoice gives invoice_number, a contract gives effective_date). Optional paid enrichment: absent when it was not ordered.

content

The document's pages, and every element on them in reading order.

FieldTypeDescription
pagesarray of pageEvery page that converted, in order. A partial conversion lists fewer pages than metadata.file.page_count.
elementsarray of elementEvery element in reading order. The array order is the reading order; do not sort by id.

metadata.file

The file as it was received.

FieldTypeDescription
filenamestringThe file's name as it was received.
media_typestringIANA media type of the file as received.
formatstringThe file's format family. image covers PNG, JPEG, TIFF, BMP and WebP.One of pdf, image, docx, pptx, xlsx, csv, txt
size_bytesintegerSize of the file as received, in bytes.
sha256stringSHA-256 of the file as received, lowercase hex. Two files with the same value are the same bytes.
page_countintegerNumber of pages. For DOCX, XLSX, CSV and TXT this is the page count of the file laid out as pages, since those formats have no fixed pages of their own. For PPTX it is the slide count, and for an image it is 1.

metadata.properties

Properties the file itself declares, such as a PDF's document information or a Word file's core properties. Output exactly as the file declares them: they are often wrong or left at a template's default ("Microsoft Word - Document1"). A field is absent when the file declares nothing for it. CSV and TXT files declare no properties.

FieldTypeDescription
titleoptionalstringPropertyDeclared title.
authorsoptionalobjectDeclared authors, meant to be people. Files often hold a company or a username here instead. A file declaring one author string gives a one-item list; names are never split.
subjectoptionalstringPropertyDeclared subject.
keywordsoptionalstringPropertyDeclared keywords, as one string exactly as the file holds them.
descriptionoptionalstringPropertyDeclared description or abstract.
createdoptionaldatePropertyDeclared creation date.
modifiedoptionaldatePropertyDeclared last-modified date.
languageoptionalobjectDeclared language, as an ISO 639-1 code. A file declaring en-US gives en.
companyoptionalstringPropertyDeclared company. Office files only.
applicationoptionalstringPropertyThe application that created or produced the file.
copyrightoptionalstringPropertyDeclared copyright or rights statement.

metadata.stats

Counts and facts computed from the converted content.

FieldTypeDescription
word_countintegerWords in the text of every element, page headers and footers included. A table counts the words in its cells, not in its Markdown rendering.
table_countintegerNumber of table elements.
figure_countintegerNumber of figure elements.
languageoptionalstringThe main language of the text, detected from the content rather than declared by the file, as an ISO 639-1 code. Absent when it cannot be detected.

metadata.processing

How and when this file was produced.

FieldTypeDescription
engine_versionstringVersion of the conversion engine. It changes whenever conversion output can change. Element ids are stable only for the same file through the same engine_version.
converted_atstringWhen the conversion ran, ISO 8601 in UTC.

metadata.extracted[]

One fact a language model read from the document.

FieldTypeDescription
namestringThe fact's name, in the document's own vocabulary, snake_case.
valuestring or nullThe value as the model read it.
source_element_idstring or nullid of the element the value was read from, or null when the model could not name one.
generated_bystringAlways llm: the value was produced by a language model, not copied from the file.One of llm

content.pages[]

FieldTypeDescription
numberintegerPage number, from 1.
widthnumberPage width in points (1/72 inch).
heightnumberPage height in points (1/72 inch).

content.elements[]

One block of the document: a heading, a paragraph, a table, a figure and so on. Each element carries everything about itself; no field points into another structure except by element id.

FieldTypeDescription
idstringElement id, p{page}-e{n}: the n-th element in reading order on the page where the element starts. Unique within the file. Stable for the same file through the same engine_version, and nothing more: do not parse it or sort by it.
typestringWhat the element is. title is the document title; heading is a section heading; paragraph is running text, and also page headers and footers (see role); list groups list_item elements; table holds cells; figure is a picture or chart; caption and footnote belong to a table, figure or code block; formula is a mathematical expression; code is a code block; checkbox is a form checkbox.One of title, heading, paragraph, list, list_item, table, figure, caption, footnote, formula, code, checkbox
rolestringbody for the document's content. header and footer for text repeated at the top or bottom of pages, such as running titles and page numbers, which most consumers filter out.One of body, header, footer
textoptionalstringThe element's text. On a table, one string for consumers who want the table as text: its caption(s), then its cells as a Markdown table, then its footnote(s), separated by blank lines; the cells are in table. The caption and footnotes are also elements of their own, so a consumer joining every element's text sees them twice. Absent on list (its text is in its items) and on figure.
rawoptionalstringThe text exactly as the source held it, present only when it differs from text (for example a list item whose source text includes its bullet).
text_sourceoptionalstringWhere text came from. embedded: the file contains the text itself. ocr: the text was recognised from pixels, so it may hold recognition errors. mixed: some of each. A scanned PDF that already carries a hidden text layer reads as embedded. Present whenever text is.One of embedded, ocr, mixed
pagesarray of integerThe pages this element is on, from 1, ascending. Empty only for an element with no position on any page.
boxesarray of pageBoxWhere the element sits, one box per region. Most elements have one; an element continuing across a page or column break has one per part. A list has the box enclosing its items, per page.
headingsarray of stringThe text of the document's own headings above this element, outermost first. Empty before the first heading. When a document marks every heading at the same level, this holds only the nearest one.
parentoptionalstringid of the list this item belongs to. On list_item only.
leveloptionalintegerHeading depth, from 1 for the outermost. On heading only.
orderedoptionalbooleanWhether the list is numbered. On list only.
markeroptionalstringThe item's own numbering or bullet as printed, such as (a), 1. or iii.. On list_item only, absent when the item has none.
checkedoptionalbooleanWhether the checkbox is ticked. On checkbox only.
code_languageoptionalstringThe programming language of the code block, when known. On code only.
tableoptionaltable
imageoptionalimage
captionsoptionalarray of stringids of this element's captions. On table, figure and code only.
footnotesoptionalarray of stringids of this element's footnotes. On table, figure and code only.

metadata.properties.title

FieldTypeDescription
valuestring
sourcestringWhere in the file the value was read.

metadata.properties.created

FieldTypeDescription
valuestringISO 8601. A date declared with a timezone is converted to UTC and ends in Z. A date declared without one is output without an offset, because the file does not say which timezone it meant.
sourcestringWhere in the file the value was read.

content.elements[].boxes[]

One region of an element, on one page. Coordinates as in a table cell's box: points, top-left origin, y growing downward.

FieldTypeDescription
pageintegerPage number, from 1.
x0numberLeft edge.
y0numberTop edge.
x1numberRight edge.
y1numberBottom edge.

content.elements[].table

The table's cells. On table only. Each cell appears once; a cell spanning several rows or columns appears at its top-left position.

FieldTypeDescription
rowsintegerNumber of rows.
colsintegerNumber of columns.
cellsarray of cell

content.elements[].image

The figure's pixels, delivered as a file beside this JSON. On figure only; absent when no image could be cut from the page.

FieldTypeDescription
filestringPath of the image file, relative to this JSON file.
media_typestringIANA media type of the image file.
widthintegerWidth in pixels.
heightintegerHeight in pixels.

content.elements[].table.cells[]

FieldTypeDescription
rowintegerRow of the cell's top-left position, from 0.
colintegerColumn of the cell's top-left position, from 0.
row_spanintegerRows the cell covers.
col_spanintegerColumns the cell covers.
headeroptionalstringcolumn: the cell heads its column. row: it heads its row. section: it is a row that labels the rows below it. Absent for a data cell. Header detection is not perfect: a header the engine missed reads as a data cell.One of column, row, section
textstringThe cell's text. Empty for an empty cell.
boxoptionalbox

content.elements[].table.cells[].box

A rectangle on a page in points (1/72 inch), origin at the top-left corner of the page, y growing downward. Every box in the file uses this one system.

FieldTypeDescription
x0numberLeft edge.
y0numberTop edge.
x1numberRight edge.
y1numberBottom edge.