officeParser
Parse Office documents into a rich AST and generate Markdown, HTML, PDF, or RAG chunks
Repository Health
Technical Analysis
officeParser is a strictly-typed Node.js and browser library that parses office documents — docx, pptx, xlsx, odt, odp, ods, pdf, rtf, csv, md, html, and epub — into a rich, hierarchical Abstract Syntax Tree rather than a flat text blob. That AST preserves structure (headings, tables, notes, formatting, attachments) so downstream code can reason about document layout, not just extract raw text.
From the same AST, the library’s generator layer can re-render the document into Markdown, HTML, CSV, RTF, PDF, EPUB, plain text, or pre-segmented RAG chunks, and an OfficeConverter wraps parse+generate into a single one-step conversion call. It ships both as a programmatic API (OfficeParser.parseOffice(), ast.to()) and a CLI (npx officeparser), with optional OCR via Tesseract for scanned/image content.
What You Get
- A unified
parseOffice()API producing a hierarchical AST across 12 input formats (docx, pptx, xlsx, odt, odp, ods, pdf, rtf, csv, md, html, epub) - An
OfficeGenerator/ast.to()layer that renders the same AST into Markdown, HTML, CSV, RTF, PDF, EPUB, plain text, or RAG chunks - A one-step
OfficeConverter.convert()API that parses and generates in a single call - Native RAG chunking output tailored for retrieval pipelines, with configurable chunk sizing
- Optional OCR (via Tesseract) for scanned images and image-embedded content, with granular timeout controls
- AbortSignal-based cancellation and non-fatal warning collection (
ast.warnings) instead of hard failures on recoverable issues - Both a Node.js/browser library API and a full-featured CLI (
npx officeparser)
Common Use Cases
- Extracting clean, structured text and metadata from user-uploaded Word/PDF/PowerPoint files for search indexing
- Building RAG ingestion pipelines that need pre-chunked, structure-aware text from office documents
- Converting legacy .docx/.odt reports into Markdown or HTML for a documentation or CMS pipeline
- Batch-converting office files to PDF or EPUB from a CLI script or CI job
- Extracting text and images (with OCR) from scanned PDFs where no text layer exists
Under The Hood
Architecture: The library separates parsing from generation: src/parsers/ holds one dedicated parser per format (WordParser, PowerPointParser, ExcelParser, PdfParser, RtfParser, OpenOfficeParser, CsvParser, MarkdownParser, HtmlParser, EpubParser), each producing a common AST node shape defined in the ~2,100-line types.ts; OfficeParser.ts dispatches to the right parser and returns the AST, while OfficeGenerator.ts and the format-specific files under src/generators/ walk that same AST to emit Markdown/HTML/CSV/RTF/PDF/EPUB/chunks, and OfficeConverter.ts composes the two into a single parse-then-generate call. Tech Stack: TypeScript compiled to dual CJS/ESM output plus a separate browser bundle (officeparser.browser.mjs/.iife.js) built via a custom build_browser.js script, with Tesseract.js for OCR and pdf.js for PDF parsing as the two heaviest runtime dependencies, versions kept in sync via a sync:pdfjs-versions script. Code Quality: The test suite is unusually broad for an npm library — dedicated suites for parser correctness, generator output, CLI behavior, security, licensing, exhaustive format coverage, and roundtrip/performance analysis (test/testExhaustive.ts, test/roundtrip_analysis.ts, test/performance_test.ts), all gated behind a test script that also runs lint and a full build first, indicating CI enforces both correctness and packaging integrity. API Design: The library favors explicit, discoverable entry points — parseOffice() for extraction, ast.to() for AST-native conversion, and OfficeConverter.convert() as a one-step shortcut — while surfacing non-fatal issues via ast.warnings instead of throwing, and documents every CLI flag (including deprecated aliases) in a single reference table, which keeps the migration path visible across major versions.
Used by 8 apps in this directory
AionUi
AI Agents · Productivity
Free, open-source Cowork desktop app that unifies Claude Code, Codex, Gemini CLI, and 20+ AI agents into a single platform with multi-agent teams, 24/7 cron automation, and zero-config built-in agent.
AnythingLLM
Developer Tools · Automation · AI Assistants
The all-in-one AI platform for private document chat, no-code agents, and local LLMs with zero setup friction.
byterover-cli
AI Agents · AI Code Assistants
A portable memory layer for AI coding agents — curate structured project knowledge into a version-controlled context tree that syncs across tools, machines, and teammates.
Cherry Studio
AI Assistants
All-in-one AI desktop client with 300+ assistants and multi-model support
Flowise
Developer Tools · Automation · No Code Platforms
Drag-and-drop visual builder for AI agents, RAG pipelines, and multi-agent systems—deploy anywhere in minutes.
LobeHub
AI Assistants · Productivity · Automation
Your Chief Agent Operator — build, schedule, and collaborate with an entire AI team in one self-hostable workspace.
Midday
Invoicing Finance · Productivity
All-in-one AI-powered business operations platform for freelancers and solo entrepreneurs to manage invoicing, time tracking, banking, and financial intelligence.
NocoBase
No Code Platforms · Low Code Platforms
Open-source AI + no-code platform that lets coding agents and people collaborate to build business systems fast on proven infrastructure.