firecrawl/anydoc
Convert Word, PowerPoint, Excel, OpenDocument, RTF, EPUB, CSV, and PDF to clean Markdown. Built in Rust, with Node.js and Python bindings.
What anydoc does
anydoc is a fast, pure‑Rust library that turns a wide range of office‑type files (Word, PowerPoint, Excel, OpenDocument, RTF, EPUB, CSV, PDF) into clean, GitHub‑Flavored Markdown. It provides the same conversion result no matter which format you start with, preserving structure (headings, tables, lists, footnotes, equations, embedded images, etc.) and emitting a single, consistent Markdown representation.
The core library is packaged for four environments:
| Language / Platform | How you use it | Typical entry point |
|---|---|---|
| Rust (crate) | cargo add anydoc then call anydoc::to_markdown… |
anydoc::to_markdown("file.docx")? |
| Node.js (npm) | npm install @firecrawl/anydoc |
await toMarkdown("file.pptx") |
| Python (PyPI) | pip install firecrawl-anydoc |
anydoc.to_markdown("file.xlsx") |
| Web (Wasm) | npm install @firecrawl/anydoc-wasm + await init() |
toMarkdownBytes(bytes) |
A tiny CLI (npx @firecrawl/anydoc …) and an Agent Skill let you call the converter from the command line or from AI‑agent frameworks with a single command.
Why it matters for AI / LLM pipelines
Large language models work best with plain text, especially Markdown that retains headings, tables, and code blocks. Any workflow that ingests user‑uploaded documents—knowledge‑base building, retrieval‑augmented generation, data extraction, or chat‑assistant file reading—needs a reliable way to turn those heterogeneous formats into a uniform text representation. anydoc provides:
- Speed – median < 5 ms per document (pure Rust, no ML models).
- Coverage – 14 formats, the only open‑source tool in the benchmark that supports them all.
- Structure preservation – headings, lists, tables, footnotes, LaTeX equations, and embedded assets are kept, so downstream LLMs can understand document hierarchy.
- Local processing – conversion runs on the client machine; only scanned PDFs that need OCR are optionally sent to Firecrawl’s hosted OCR service.
These traits make it a solid building block for any system that needs to feed “LLM‑ready” text from arbitrary office files.
How it works (high‑level)
- Format detection – reads magic bytes (PDF header, OLE streams, ZIP mimetypes, etc.) to infer the file type, ignoring the file extension.
- Per‑format parser – a dedicated parser extracts a shared document model (blocks, inlines, tables, footnotes, assets) for each supported format.
- Unified serializer – the model is passed to a single GitHub‑Flavored Markdown serializer, guaranteeing consistent escaping, heading anchors, table formatting, etc.
- PDF path – text‑based PDFs are handled locally via the
pdf‑inspectorcrate. Scanned PDFs raise aNeedsOcrerror; you can opt‑in to send them to Firecrawl Parse (hosted OCR) which returns the same Markdown.
Because every format funnels through the same model, bug fixes or feature improvements automatically benefit all formats.
Getting started (quick examples)
CLI (no install needed)
npx @firecrawl/anydoc report.docx # prints Markdown to stdout
npx @firecrawl/anydoc slides.pptx -o out.md
npx @firecrawl/anydoc scan.pdf --ocr hosted # uses hosted OCR for scanned PDFs
Node.js
import { toMarkdown } from '@firecrawl/anydoc';
const md = await toMarkdown('report.docx');
Python
import anydoc
md = anydoc.to_markdown('report.docx')
Rust
let md = anydoc::to_markdown("report.docx")?;
Limitations & gotchas
- No built‑in OCR – pure‑Rust conversion only handles text‑based PDFs. Scanned PDFs must be sent to the optional hosted OCR service (
ocr: "hosted"). - Encrypted / password‑protected files raise
Encryptedand cannot be converted. - Resource limits – very deeply nested or huge archives may hit safety caps (decompression, node count) and return
ResourceLimit. - Rust crate does not expose OCR; only the Node/Python bindings can forward to the hosted service.
Who might use it?
- LLM‑powered assistants that need to read user‑uploaded docs (e.g., ChatGPT plugins, Claude agents).
- RAG pipelines building searchable knowledge bases from mixed office files.
- Data‑extraction tools that convert tables, forms, or reports into structured text.
- Automation scripts that batch‑process documents for indexing, summarisation, or translation.
License
MIT – free for commercial and non‑commercial use.
Related
- Project
- Project
- Project
- Project
- Project