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:

  • text and markdown for straightforward reading and rendering
  • pages for coordinate spaces and reading order
  • elements for text, tables, figures, formulas, key-values, and other semantic content
  • relations for hierarchy and cross-element links without duplicating trees
  • text_annotations for language and style over ranges in text
  • assets for 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/schema

The 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.

On this page