any-extractor
v3.1.0
Published
Turn any document (PDF, Word, Excel, PowerPoint, OpenDocument, HTML, JSON, CSV, text) into agent-ready markdown, typed blocks, and metadata — one call, with an optional custom-parser hook for vision LLMs and bespoke formats.
Downloads
118
Maintainers
Readme
any-extractor
One
extract()call. Any document. Agent-ready markdown, typed blocks, and metadata.
Point it at a file, URL, or Buffer. Get back:
markdown— a single GFM string, ready for an LLM.text— plain reading-order text, ready for embeddings or search.sections— ordered pages / slides / sheets with typed blocks.metadata— MIME, title, author, page count, sheet names.
import { extract } from 'any-extractor';
const result = await extract('./quarterly-report.pdf');
result.markdown; // GFM string
result.text; // plain text
result.sections; // typed blocks
result.metadata; // { mime, title, pageCount, ... }result.markdown
# Q3 Results
Revenue grew **18%** year-over-year, driven by APAC.
| Region | Revenue |
| ------ | ------- |
| APAC | $4.2M |
| EMEA | $3.1M |result.sections
[
{
kind: 'page',
label: 'Page 1',
index: 1,
blocks: [
{ id: 'a1b2…', type: 'heading', level: 1, text: 'Q3 Results' },
{
id: 'c3d4…',
type: 'paragraph',
text: 'Revenue grew **18%** year-over-year, driven by APAC.',
},
{
id: 'e5f6…',
type: 'table',
headers: ['Region', 'Revenue'],
rows: [
['APAC', '$4.2M'],
['EMEA', '$3.1M'],
],
},
],
},
];result.metadata
{
mime: 'application/pdf',
source: './quarterly-report.pdf',
title: 'Q3 Results',
author: 'Finance Team',
pageCount: 42,
}Install
npm install any-extractorNode.js ≥ 18.
MCP Server
any-extractor doubles as a Model Context Protocol server. Drop it into Claude Desktop, Cursor, VS Code, Continue, or any MCP-capable agent.
{
"mcpServers": {
"any-extractor": {
"command": "npx",
"args": ["-y", "any-extractor-mcp"],
},
},
}| Tool | Use it for |
| ----------------------------- | ------------------------------------------------------------- |
| extract_document | Default. Markdown + metadata + section index. |
| extract_document_structured | Full typed section/block tree — for agents that walk content. |
| extract_section | One section by index. Cheap paging for large PDFs. |
Supported formats
| Format | Sections emitted |
| ------------ | -------------------------- |
| PDF | one page per page |
| Word | single body |
| Excel | one sheet per worksheet |
| PowerPoint | one slide per slide |
| OpenDocument | body / sheet / slide |
| HTML | single body |
| Markdown | single body |
| Plain text | single body |
| CSV | single body |
| JSON | single body |
CLI
# Markdown to stdout (default)
npx any-extractor report.pdf
# Everything else — flags, formats, URLs, stdin, timeouts
npx any-extractor --helpProgrammatic API
Cancellation & timeouts
// User-driven cancel
const ac = new AbortController();
await extract('./big.pdf', { signal: ac.signal });
// Hard deadline
await extract(url, { timeoutMs: 10_000 });
// Both — whichever fires first wins
await extract(url, { signal: ac.signal, timeoutMs: 30_000 });Custom parsers
Register your own MIME handler — e.g. route images through a vision LLM. User parsers override built-ins, and embedded images inside Word / PowerPoint / OpenDocument get enriched automatically.
import { AnyExtractor } from 'any-extractor';
const extractor = new AnyExtractor();
extractor.addParser({
mimes: ['image/png', 'image/jpeg'],
concurrency: 2, // rate-limit in-flight calls
async parse(buffer, ctx) {
const caption = await myVisionModel(buffer);
return {
sections: [{ kind: 'body', blocks: [ctx.block.paragraph(caption)] }],
};
},
});
await extractor.extract('./slides.pptx');Enriched images render with a blockquote caption in the output markdown:

> Bar chart showing Q3 revenue up 18% vs. Q2, driven by APAC.Support
If any-extractor saved you an afternoon, you can — it keeps the parsers fed.
