Extract PDF Text (PyMuPDF)
Feed your document to an LLM without the pixels
- text
- page_count
If the whole point of a document is what it says rather than how it looks, this is the node you want. Extract PDF Text (PyMuPDF) pulls the words out of a PDF without rendering a single image, which makes it fast, light on VRAM, and the natural front end for anything that feeds a local LLM or a document-Q&A chain in the graph. It's the focused sibling of Extract PDF (PyMuPDF) - same text engine, none of the image extraction overhead.
How it works
PyMuPDF has a whole family of text extraction modes, and this node exposes them all through one format dropdown, backed by page.get_text(format):
text- plain text, the default and what you'll use 95% of the time.blocks/words- spatial layout data: text blocks or individual words with their positions, which you'd use for column-aware extraction or reconstructing where things sit on the page.html/xhtml/xml- the same text wrapped in markup, if you're doing downstream HTML or XML processing.json- PyMuPDF'sdictmode serialized to JSON, the richest format: per-line, per-span text with font, size, and bounding boxes. This is the one to pick when you need font-aware extraction or want to rebuild the page layout.
Each page's output gets prefixed with a --- filename page N --- header and joined into one STRING. The page_range input takes all (default) or a 1-based list like 1,2 or 3-5; max_pages (default 0 = no limit) caps how many pages you walk through for the big documents.
What comes out and where it goes
Two outputs:
text(STRING) - the whole extract. Wire it to a text preview/display node, intoSave PDF Text (PyMuPDF)to write it to the output folder as.txt,.json, or.md, or feed it to an in-graph LLM node for summarization and Q&A. The document-to-LLM pattern is one of the rare non-diffusion jobs ComfyUI genuinely handles well, and text nodes like this are the plumbing that make it work.page_count(INT) - total pages in the document, useful for routing or for sanity-checking that yourpage_rangeactually covered what you thought.
Install & gotchas
Standard pack install: ComfyUI Manager (search "ComfyUI PyMuPDF") or clone the repo into custom_nodes and pip install -r requirements.txt, then restart. The dependency list is literally one line - PyMuPDF - and there are no model files to fetch.
Where people get burned: the json mode returns a lot of text (font/bbox info per character), so a 200-page PDF in json mode is megabytes of string flowing through your graph, and the UI truncates what it shows you at 20,000 characters even though the full string is still on the output. If your document is scanned (images of text with no selectable text layer), this node returns nothing regardless of format - you want Render PDF Pages (PyMuPDF) plus an OCR/vision model instead, not more text extraction.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| PYMUPDF_PDF | — | ||
| page_range | STRING | all | — |
| format | COMBO | 7 options: text, blocks, words, html, xhtml, xml, +1 | |
| max_pages | INT | 00–10000 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |
| page_count | INT | — |