distill
Why
Coding agents read PDFs the expensive way. We asked Anthropic's token counting API how many input tokens Claude needs for five demo PDFs, once as the raw PDF and once as distill's Markdown:
Document | Pages | Raw PDF | distill Markdown | Saved |
| 7 | 14,021 | 2,829 | −80% |
| 8 | 16,518 | 3,870 | −77% |
| 12 | 24,978 | 6,357 | −75% |
| 9 | 24,091 | 9,871 | −59% |
| 7 | 18,693 | 8,066 | −57% |
Total | 43 | 98.3k | 31.0k | −68% |
Measured on 2026-11-07 with POST /v1/messages/count_tokens and claude-sonnet-5-5. The documents are generated by scripts/marketing/make-demo-docs.mjs and the numbers are reproducible with npm run marketing:measure. Your files will differ.
On top of that, distill's lossless boosters trim another 10% from LiteParse's Markdown on the same files (24.9k → 22.4k o200k_base tokens). LiteParse already returns clean Markdown, so that extra step is modest; it is bigger on table- and link-heavy documents.
Related MCP server: packforai-mcp
Features
One engine, many doors. The same local pipeline behind a web app, a desktop app, a Docker image, a CLI, an MCP server and hooks for Claude Code and OpenCode.
Real parsing. LiteParse by LlamaIndex reads PDFs and images (with OCR). DOCX, PPTX, XLSX and CSV use a built-in reader, or LiteParse through LibreOffice when it is installed; legacy Office and ODF go through LibreOffice.
Lossless boosters. Small, deterministic passes drop repeated boilerplate, image paths and link targets, table padding and extra whitespace. Content words stay.
Optional LLMLingua-2. A local model for when you want to go further and accept a lossy result. Off by default, installed on demand.
Honest numbers. Every file's before and after token counts come from a real tokenizer, live in the UI.
Private by design. Files are parsed on your machine. No telemetry, no analytics, no CDN.
Quick start
npx distill-llmThis starts a local server at http://127.0.0.1:4321 and opens the web UI. Drop files in, read the Markdown, copy it or download it (one .md or a ZIP of all of them).
Use it from your agent
MCP server
Give any MCP client three tools: distill_file, distill_files and distill_capabilities. From 0.4.0 on, every release is listed in the official MCP registry as io.github.nievesjesus/distill. Results end with a [distill] tokens saved ≈ … line telling the model how many tokens distill saved (the PDF baseline is an estimate of Claude reading the PDF directly: its text plus about 1,560 tokens per page; the Office baseline is the raw extracted text), and DISTILL_NO_SAVINGS_NOTE=1 turns the line off.
Results are capped at 10,000 tokens (DISTILL_MCP_MAX_TOKENS changes it) so they fit an agent's tool-result limit. A larger document comes back one page at a time: pass the nextOffset from the previous distill_file result as offset to continue, and distill_files returns what fits and tells the model which files to request on their own.
claude mcp add distill -- npx -y distill-llm mcpAny other client:
{
"mcpServers": {
"distill": { "command": "npx", "args": ["-y", "distill-llm", "mcp"] }
}
}distill_file({ path, boosters?, lingua? }) returns the Markdown plus { tokens: { raw, out }, pages, kind }. distill_files takes up to 20 paths and reports a per-file error instead of failing the whole call.
For clients that speak HTTP, distill-llm mcp --http serves Streamable HTTP at http://127.0.0.1:4322/mcp. Over HTTP the server only reads files inside the directories you pass with --root (repeatable, default: the current directory) and compares real paths, so symlinks cannot escape. It rejects cross-site requests and answers only to loopback names, IP addresses and the hostnames you list with --allowed-hosts, which blocks DNS rebinding.
The HTTP server has no authentication: anyone who can reach it can read every file under --root. Never publish it directly to the internet. To use it from a remote client:
Point
--rootat a folder that holds only the documents you want to share.Put an HTTPS tunnel with authentication in front of it (for example Cloudflare Tunnel with Cloudflare Access, or Tailscale Funnel restricted to your tailnet).
Allow the tunnel's hostname, or every request gets 403:
distill-llm mcp --http --root ~/shared-docs --allowed-hosts distill.example.comAdd
https://distill.example.com/mcpas the connector URL in your client.
Claude Code plugin
claude plugin marketplace add nievesjesus/distill
claude plugin install distill@distillThe plugin adds the Read hook for PDF and Office files, the distill MCP server and the Office skill, with no other setup. It needs Node.js 22.12 or newer: it runs npx distill-llm@<plugin version>, so the first conversion downloads the package. Do not combine it with hooks install --claude: if both exist the plugin steps aside and the settings hook does the work. Remove one of them with distill-llm hooks uninstall --claude.
Hooks: make your agent read Markdown instead of the binary
npm i -g distill-llm
distill-llm hooks install --claude # Claude Code
distill-llm hooks install --opencode # OpenCodeClaude Code: adds a
PreToolUsehook onReadto~/.claude/settings.json(or your personal.claude/settings.local.jsonwith--project). When Claude reads a PDF inside the project it is working in, the hook converts it once, caches it by content hash in~/.cache/distill-llm/out/(private to your user) and points the read at the Markdown. It also adds the permission ruleRead(~/.cache/distill-llm/out/**)so those reads do not prompt. Claude Code refuses Office files before any hook runs (checked on Claude Code 2.1.296), so the installer also writes the skilldistill-office-documentsto~/.claude/skills/(or.claude/skills/with--project). It has Claude rundistill-llm convert --stdoutthrough Bash for.docx,.doc,.xlsx,.xls,.pptx,.ppt,.odt,.odsand.odpfiles. Claude Code asks before each of those Bash calls unless you allow it; distill does not add that permission, because Bash is not subject toReaddeny rules. ASKILL.mdyou wrote yourself is left alone.OpenCode (experimental): writes a plugin to
~/.config/opencode/plugins/distill.js(or.opencode/plugins/with--project) that does the same ontool.execute.beforeforread. OpenCode's plugin API is changing; if the plugin does not apply, OpenCode simply reads the original file.
The installer shows the exact change and asks before writing (--yes skips the question). It keeps your other settings, follows symlinked dotfiles, keeps the file mode, and masks existing values in the diff it prints. distill-llm hooks uninstall --claude|--opencode removes only what it added, including the skill. Install it globally first: a command written from a temporary npx run would disappear.
The hooks respect your permissions and never block a read:
Files outside the project the agent works in are not converted, so Claude Code asks you about them as usual.
The Claude Code hook steps aside when a
denyoraskrule forReadin your user, project (any parent folder orCLAUDE_PROJECT_DIR), local or managed settings could match the file being read (or its real path) or distill's cache. Relative rules are checked against the working directory and the folder that holds the settings file. A rule it cannot interpret (character classes, braces,!,$, a~without/,.or..segments) counts as matching. If a settings file can't be read, the hook stays out of the way entirely. Rules passed on the command line (--settings,--disallowedTools) are invisible to hooks.Images and CSV files are left alone.
If anything fails (a missing file, a timeout, a password-protected PDF, a scan with no text), the agent reads the original file.
Set DISTILL_HOOK=off to disable the Claude Code hook for a session. Conversions, fresh or served from the cache, end the hook's context with a [distill] tokens saved ≈ … line (the PDF baseline is an estimate of Claude reading the PDF directly: its text plus about 1,560 tokens per page; the Office baseline is the raw extracted text), distill-llm convert --stdout prints the same line on stderr, and DISTILL_NO_SAVINGS_NOTE=1 turns the line off.
CLI
npx distill-llm convert report.pdf deck.pptx --out md/Option | Does |
| Write the |
| Only these boosters: |
| Plain LiteParse Markdown, no boosters |
| Add LLMLingua-2 (must be installed from the web app first) |
| Print a JSON array with tokens, pages and timings per file |
| Print the Markdown of a single file instead of writing it |
distill-llm update [--yes] checks for a newer version right away. A global npm install updates after a y/N question (or straight away with --yes); other installs print the command to run. After convert on a terminal, and when the web app starts, a one-line notice goes to stderr if a newer version exists (never with --json or --stdout).
Each file prints a summary such as report.pdf → report.md 5.7k → 4.6k tokens (−19%). The exit code is 1 if any file failed; the others are still converted.
Desktop app and Docker
Desktop: installers for macOS (arm64, x64), Windows (x64) and Linux (x64) are on GitHub Releases. They are named without a version (Distill-lite-mac-arm64.dmg, Distill-lite-mac-x64.dmg, Distill-lite-win-x64.exe, Distill-lite-linux-x86_64.AppImage), so https://github.com/nievesjesus/distill/releases/latest/download/<file> always points at the newest release. Distill-lite-* has everything except LLMLingua-2; Distill-full-* bundles its runtime and is published for Apple Silicon, Windows x64 and Linux x64. Intel Macs get the lite build only.
macOS 15 and later: open the app once and dismiss the warning, then go to System Settings > Privacy & Security and click Open Anyway.
macOS 14 and earlier: right-click the app, choose Open, then confirm Open.
"The app is damaged": run
xattr -dr com.apple.quarantine /Applications/distill.appand open it again.Windows: in the SmartScreen dialog click More info, then Run anyway.
Release builds are signed when the signing certificates are configured; if your installer is unsigned, the steps above apply. The desktop app checks GitHub Releases for a newer version at most once a day (same toggle and DISTILL_NO_UPDATE_CHECK as above), 5 seconds after launch, and shows a banner. It downloads and installs only when you click Download and install, then offers Restart to update (or installs on the next quit). Updates stay within your variant (lite or full) and never downgrade. OCR data is bundled; DOCX, XLSX, PPTX and CSV work out of the box, while .doc, .xls, .ppt and OpenDocument files need LibreOffice installed.
Docker: LibreOffice and the English OCR data are included, so every format works out of the box, including .doc, .xls, .ppt and OpenDocument.
docker run --rm -p 4321:4321 -v distill-cache:/home/node/.cache ghcr.io/nievesjesus/distillOpen it as http://localhost:4321 or by IP, or pass -e DISTILL_ALLOWED_HOSTS=<name> to reach it by hostname. Build it yourself with docker build -t distill ..
How it works
flowchart LR
A[PDF · DOCX · PPTX · XLSX · images] --> B[LiteParse<br/>local parse + OCR]
B --> C[Boosters<br/>dedupe · media · tables · ws]
C --> D{LLMLingua-2?<br/>optional, lossy}
D --> E[Markdown + token counts]
E --> F[Web · Desktop · CLI · MCP · Hooks]Booster | What it does | Loss |
Drop repeated boilerplate | Removes identical running header/footer lines (4+ words, 25+ chars, 3+ repeats) and page-number lines such as | None |
Slim images and links |
| Drops image paths and URLs |
Compact tables | Removes alignment padding from GFM tables | None |
Collapse whitespace | Collapses blank-line runs, trailing and double spaces outside code | None |
LLMLingua-2 | A local model removes low-value words | Lossy, off by default |
Boosters are pure, idempotent functions and never touch fenced code blocks or front matter. In the web app they run in your browser, so switching one on or off updates the counts instantly. If you need link targets, turn off "Slim images and links".
LLMLingua-2 is optional and experimental. It needs Apple Silicon, Windows x64 or Linux x64: its ONNX runtime has no Intel Mac build, so on Intel Macs the row explains this instead of offering an install. When npm is available, its row shows Install (~520 MB): one click runs npm ci --omit=dev --include=peer --ignore-scripts against a lockfile with pinned versions and integrity hashes and installs the runtime into ~/.cache/distill-llm/lingua. The first use downloads the model (TinyBERT, about 57 MB) from Hugging Face into ~/.cache/distill-llm/models; after that it runs offline. Behind a proxy that intercepts HTTPS, give Node your organization's CA with NODE_EXTRA_CA_CERTS=/path/to/ca.pem. Never turn off certificate checks.
Supported formats
Format | Needs |
nothing else | |
PNG, JPG, TIFF, WebP | nothing else (OCR built in; English data is downloaded once, about 15 MB) |
DOCX, PPTX, XLSX, CSV | nothing else (built-in reader); with LibreOffice on your |
DOC, XLS, PPT, ODT, ODS, ODP | LibreOffice on your |
Password-protected PDFs are reported as an error. Parsing quality is whatever LiteParse gives you: it varies on dense tables and complex scans, and distill does not try to hide that.
Privacy
Files are parsed locally and never leave your machine. There is no telemetry, no analytics and no CDN: fonts are bundled. distill makes at most three one-time downloads, all of data and never of your documents: the Tesseract English data for the first OCR (skip it with DISTILL_TESSDATA or TESSDATA_PREFIX; DISTILL_OCR_LANG sets the language), and, only if you enable LLMLingua-2, its runtime from npm and its model from Hugging Face.
Once a day distill also asks registry.npmjs.org for the latest distill-llm version, sending only its own version in the User-Agent, and caches the answer in ~/.cache/distill-llm/update-check.json. Turn it off with DISTILL_NO_UPDATE_CHECK=1 or in the web app (click the version in the header, then "Check for updates daily"). The desktop app does not ask registry.npmjs.org; it asks github.com for its release manifest instead, with the same toggle. The hooks and the MCP server never check.
Uploaded files go to a temporary directory and are deleted after parsing. Results stay in a small in-memory cache so the JSON view can be requested later. The hooks write converted Markdown to ~/.cache/distill-llm/out/. API responses are sent with Cache-Control: no-store.
The web server only listens on loopback by default. --host 0.0.0.0 exposes it to your network and disables the loopback check, so only do that on a network you trust: there is no authentication. On every host, state-changing /api requests are rejected when the browser marks them cross-site or when their Origin differs from the Host. When exposed, the server only answers to loopback names, IP addresses and the hostnames you list with --allowed-hosts or DISTILL_ALLOWED_HOSTS, which blocks DNS rebinding. A reverse proxy must keep the original Host header.
How tokens are counted
The app and the CLI count with o200k_base (via gpt-tokenizer). Claude and Gemini tokenize differently, so absolute counts are approximate, while the percentage saved is comparable across tokenizers. The Claude numbers at the top of this page come from Anthropic's own token counting API.
FAQ
Is it free? Yes. Apache-2.0, no account, no paid tier.
Does anything leave my machine? Your documents never do. See Privacy for the optional one-time data downloads and the daily version check you can turn off.
How do I update? The web app and the CLI tell you when a new version exists. With a global npm install, click Update in the web app (loopback only) or run distill-llm update, then restart distill. With npx, run npx distill-llm@latest. With Docker, run docker pull ghcr.io/nievesjesus/distill. With the desktop app, use the banner (or the version menu). Installs from before 0.2.0 have no updater: download the new installer once from GitHub Releases.
Why not just give the PDF to the model? You can, and for charts and layout-heavy pages you sometimes should. For text, the same content as Markdown costs a fraction of the tokens: about a third on our demo files.
Will the hook break my agent? No. It only touches PDF reads inside your project (Office files go through the skill and a Bash call you approve), never blocks a read, steps aside when a Read deny or ask rule could match, and falls back to the original file on any error.
Is LLMLingua-2 safe to use on contracts? It is lossy by design: it removes words. Keep it off when every word matters.
Roadmap
Web app, desktop app and Docker image
CLI (
distill-llm convert)MCP server (stdio and HTTP)
Hooks for Claude Code and OpenCode
Signed and notarized desktop builds
Hooks for more agents as their hook APIs settle (Codex, Gemini CLI)
Password-protected PDFs
Ideas and votes are welcome in Issues.
Contributing
git clone https://github.com/nievesjesus/distill && cd distill
npm ci
npm test # unit tests
npm run typecheck
npm run build
npm run test:e2e # Playwright, web app
npm run test:smoke # built CLI: convert, MCP, hooksSee CONTRIBUTING.md. npm run marketing regenerates the demo documents, screenshots and banner from the real app.
Build one architecture per host: npm run dist:full -- --arm64 on Apple Silicon or npm run dist:full -- --x64 on Windows or Linux (Intel Macs only get dist:lite). build/lingua holds only the sharp binary of the machine that ran npm ci, so a cross-architecture installer would ship the wrong native module. Re-running the release workflow for a tag whose draft release already exists does not replace its installers; delete the draft first.
License
Apache-2.0. Built on LiteParse by LlamaIndex.
If distill saves you tokens, a ⭐ helps other people find it.
Available Tools
3 toolsdistill_capabilitiesA
Report versions, limits and available features (LibreOffice, LLMLingua-2)
Inputs: no named parameters. Returns: lingua, version, maxBytes, libreoffice, +1 more
distill_fileA
Convert a document (PDF, DOCX, PPTX, XLSX, ODF, image) to token-lean Markdown; large documents come back in pages
Inputs: path (required), lingua, offset, boosters. Returns: kind, note, lines, pages, +6 more
distill_filesA
Convert up to 20 documents to token-lean Markdown; a failing file does not fail the call. Output is capped: a file that does not fit is returned in part and later files are skipped
Inputs: paths (required), lingua, boosters. Returns: note, total, results, continuation
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
distill_file and distill_files overlap in purpose (singular vs batch conversion), which could cause a moment of hesitation, but the descriptions clearly differentiate single-document versus up-to-20-document batches. distill_capabilities is clearly distinct as a metadata/reporting tool.
All three tools use a consistent snake_case distill_<noun> pattern. The singular/plural distinction between distill_file and distill_files is a predictable and readable convention.
Three tools is a tight, well-scoped surface for a document-conversion server: one for single files, one for batch, and one for capability discovery. Each tool earns its place with no redundancy.
The surface covers single conversion, batch conversion, and capability reporting, which is the core lifecycle for this domain. A minor gap is the lack of an explicit continuation/retrieval mechanism for documents that come back in pages or partial output, which could create a dead end for large files.
Maintenance
Related MCP Connectors
Convert PDF, Word, Excel, PowerPoint, e-mails and web pages to clean Markdown for LLMs.
Document to Markdown: convert Word, Excel, PowerPoint and PDF files to Markdown for an LLM.
PDF, Word, PowerPoint, Excel, HTML, EPUB to clean Markdown for LLMs/RAG; OCR for scans; chunks.
Convert PDF, DOCX, XLSX and 25 other formats to clean Markdown for LLMs and RAG. No key or account.
Related MCP Servers
- AlicenseAqualityCmaintenanceConverts documents between Markdown, PDF, DOCX, and HTML locally with AI-friendly Markdown output and secure file access.6MIT
- AlicenseAqualityDmaintenanceConverts PDF, DOCX, PPTX, XLSX, CSV, and JSON into clean, compact, AI-ready Markdown, reducing tokens up to 65%.132 npmMIT
- AlicenseNot gradedqualityCmaintenanceConverts PDFs, Office files, spreadsheets, emails, audio, and more to Markdown locally, enabling AI assistants to read and process them without cloud upload.MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to convert PDF, Word, PowerPoint, Excel, HTML, EPUB, Outlook messages and web pages into Markdown for LLM and RAG workflows. Runs over stdio or HTTP and reproduces Microsoft markitdown's output byte for byte without a Python environment.4MIT