Nodes/ComfyUI-Documents/Document Loader
ComfyUI Node

Document Loader

Getting a PDF, DOCX, or TXT into ComfyUI as plain text

By Excidos·Created 2 years ago·Updated 2 years ago· 67
Document Loader
    • parsed_text
    file_path

    If you've only ever used ComfyUI for image generation, this node looks out of place - and that's the point. Document Loader is the front door for a small pack (ComfyUI-Documents) that treats ComfyUI as a general graph engine, not just a Stable Diffusion front end: point it at a PDF, TXT, DOC, or DOCX file, and it hands you back the text so you can wire it into whatever comes next, whether that's a chunker, a text encode node, or an LLM/agent node from another pack.

    What it actually does

    It's a file picker plus a parser, nothing more exotic than that. The file_path field is a dropdown populated from whatever's sitting in your ComfyUI input/ folder - the same convention the built-in Load Image node uses - or you can drag-and-drop a file straight onto the node to upload it. Behind the scenes it reads the file with PyMuPDF for PDFs and python-docx for Word files, pulls the text out, and passes it downstream.

    One thing worth flagging up front: the pack's own README talks about extracting "text content, images, and metadata," but the node's actual output is a single parsed_text string. If you're expecting images or metadata to fall out of this node too, they don't - for images, you want PDFToImage or PDFPageSplitter instead. Document Loader is text-only, and that's fine; it just means don't go hunting for an image output that isn't there.

    The one input, the one output

    There's really only one thing to set: file_path, the document you want parsed. No page ranges, no format toggles - it auto-detects PDF vs. TXT vs. DOC/DOCX from the extension and handles each accordingly.

    The output is parsed_text (a plain STRING). That's your entire document as one block of text, ready to plug into a Text Chunker node if it's long, into a CLIP Text Encode if you're doing something creative with it, or into whatever LLM/agent node you're using if the point is to have a model reason over the document.

    Installing it

    Easiest path: open ComfyUI Manager and search for ComfyUI-Documents - it's listed there, install and restart. By hand, it's the usual drill:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Excidos/ComfyUI-Documents.git
    pip install -r ComfyUI-Documents/requirements.txt
    

    Restart ComfyUI afterward. The requirements pull in PyMuPDF and python-docx, both of which are pure-Python-friendly and shouldn't fight with the rest of your environment - but as with any custom node, installing it means running someone else's code with your user account, so it's worth a quick look at the repo before you clone it, especially for a small one-person pack like this.

    Where people get burned

    Worth knowing this is a small pack - it started life as the author's first-ever custom node, built to solve their own PDF-parsing problem for an LLM/agent workflow. It isn't battle-tested at Impact Pack scale, so a few honest caveats:

    • Legacy .doc files are the shakiest format. python-docx, which this node leans on for Word documents, is built for the modern .docx XML format. An old binary .doc from Word 2003 or earlier is a different file format entirely, and it's the format most likely to trip this node up. If you hit an error on a .doc, try re-saving it as .docx first.
    • Scanned PDFs come back empty (or garbled). PyMuPDF extracts the text layer of a PDF - it doesn't do OCR. If your PDF is a scan (a photo of a page saved as PDF, with no underlying text), parsed_text will be blank or near-empty. For that case, skip this node and use PDFToImage instead, then feed the rendered pages into a vision/OCR-capable node.
    • File not showing up in the dropdown? It has to live in ComfyUI's input/ directory, same as any image you'd load with the built-in loader. Use the upload button on the node itself if you don't want to manually move files around.
    Categorydocument_processing

    Inputs (1)

    NameTypeDefaultDescription
    file_pathCOMBO0 options:

    Outputs (1)

    NameTypeDescription
    parsed_textSTRING