Overview
Zod schemas and TypeScript types for openparser@1 documents and raw OCR envelopes.
openparser@1 is a JSON protocol for representing a parsed document once,
independently of the OCR or document AI provider that produced it. It preserves
reading order, layout, semantic elements, relationships, confidence, and assets
in one predictable document graph.
Use it when you need to switch providers without rewriting downstream code, render parsed documents consistently, trace extracted values back to source regions, or store parse results in a stable format.
Protocol at a glance
An openparser@1 document gives you:
textandmarkdownfor straightforward reading and renderingpagesfor coordinate spaces and reading orderelementsfor text, tables, figures, formulas, key-values, and other semantic contentrelationsfor hierarchy and cross-element links without duplicating treestext_annotationsfor language and style over ranges intextassetsfor page images, figures, and other binary content
The graph is provider-neutral. Provider-specific output remains available
separately through the raw format when you need it. Published object schemas
are strict; incompatible changes require a new output_format revision.
Install
npm install @openparser/schemaThe package provides the Zod schemas and TypeScript types for openparser@1
documents and the generic raw OCR envelope.
Import
Import from the package root (@openparser/schema):
import {
ParsedDocumentSchema,
RawParseResultSchema,
OcrOutputFormatSchema,
type ParsedDocument,
type RawParseResult,
} from '@openparser/schema';Use ParsedDocumentSchema.parse(json) to validate runtime data. Narrow adapter
output with ParsedDocumentWithElementKinds<'text' | 'table'> when you know
which element kinds a converter may emit.