Nodes/WAS Node Suite v3/Convert DOC to Plaintext
ComfyUI Node Runs on cloud

Convert DOC to Plaintext

Documents are formatted; prompts are not — strip the markup, keep the shape

By WASasquatch·Created 3 years ago·Updated 4 days ago· 1,844
Convert DOC to Plaintext
  • doc
  • TEXT
line_width0
links
images
tables

Sometimes you don't want the markup - you want the words, in an order and a shape a human can actually read. That's this node. Feed it a DOC (the document value that travels WAS Suite's wires, holding its content as HTML), and it lays that content out as clean plain text: a blank line between paragraphs, headings underlined rather than styled, list items marked and indented, tables in columns that line up, quotations prefixed >, preformatted blocks left as written. Markup, styling and comments are gone, and an entity like & arrives as the character it stands for.

Where does that earn its keep? Turn a formatted document into prompt-able text for a text or LLM node. Produce a readable .txt from a document pipeline. Feed Text to Console for a quick look. The one-sentence version: WAS's sibling node Convert DOC to HTML gives you the markup; this one gives you what a reader sees.

How it works and the inputs that matter

This is a structured plain-text renderer, not a regex that hunts for angle brackets - that's why the shape survives and why tables come out as aligned columns rather than soup. Four widgets control the output:

  • line_width - how many characters a line may hold before wrapping. 0 (the default) leaves each paragraph on one long line, which is what you want if the text is heading into a prompt. 72 or 80 suits a text file someone reads on its own. Wrapping counts the indent, so a list item wraps to its own column, and a long word is never broken - a line holding one web address stays over it.
  • links - text and url writes Site (https://example.org), text only drops the address, footnotes numbers it as Site[1] and lists them at the end.
  • images - what stands in for a picture: alt text ([A grey cat]), alt text and source, or skip. A picture with no description of its own becomes [image].
  • tables - aligned columns pads cells so columns line up under a rule below the header; tab separated pads nothing, for pasting into a spreadsheet.

The output is TEXT (STRING): the document as plain text with no blank line at either end and no trailing spaces on any line. Like its HTML sibling it's an output node, so it runs even when nothing is wired after it - handy for ending a branch on the node and just reading the panel. Where the document holds nothing a reader would see, it answers an empty string.

Installing it and the .docx caveat

Same pack install as the rest of WAS Node Suite v3 - ComfyUI Manager, search WAS Node Suite v3, or clone the repo into custom_nodes. No weights, no extra packages for this node.

If your documents start as real .docx or .odt files, Load Document converts those through python-docx and odfdo, which ship with the optional document_export group; without them it raises and names the missing package. .wasdoc files - Save DOC's own container - need nothing, since the container's markup is plain HTML inside.

What trips people up

If the node returns an empty string, the document genuinely holds no visible content - check the upstream producer, not this node. And remember the metadata (title, author) is deliberately not part of the text; a picture can't be drawn in text, so an embedded image only survives if it has alt text you asked to keep. Both behaviors are the point, but they surprise people the first time.

CategoryWAS Suite/Document

Inputs (5)

NameTypeDefaultDescription
docDOCThe document to convert, from any node with a DOC output. Only its content is read: the title, the author and the rest of the metadata are not part of the text, and neither is an embedded picture, since a picture cannot be drawn in text. Nothing is opened from disk.
line_widthINT00–1024How many characters a line may hold before it wraps. 0 leaves each paragraph on one long line, for a prompt; 72 or 80 suits a text file read on its own.
linksCOMBOWhat happens to the address behind a link. 'text and url' writes it in brackets, 'Site (https://example.org)'; 'text only' drops it; 'footnotes' numbers it, 'Site[1]', and lists them at the end.
imagesCOMBOWhat stands in for a picture. 'alt text' writes its description in square brackets, '[A grey cat]'; 'alt text and source' adds the file it comes from; 'skip' leaves nothing at all.
tablesCOMBOHow a table is written. 'aligned columns' pads cells with spaces so the columns line up under a rule below the header row; 'tab separated' pads nothing, for pasting into a spreadsheet.

Outputs (1)

NameTypeDescription
TEXTSTRINGThe document as plain text, with no blank line at either end and no trailing spaces on any line. Empty where the document holds nothing a reader would see, which a node saving it writes as an empty file.