All guides

Dify document text extraction: checking the text output after upload

Use Dify's Document Extractor to turn uploaded files into text, tell single-file strings from array outputs, and check order before the LLM.

AINavWritten / Updated Sources checked
On this page

At a glance

This tutorial follows the Dify Document Extractor documentation for a single DOCX: upload it, extract text, check its structure and pass it to an LLM for questions. Arrays are compared only as an output contract, not executed here. Node capabilities come from the documentation; the example, acceptance checks and stopping advice are editorial guidance. Nothing was run in this batch.

Mechanism overview

  1. Input layer

    Input layer: a file variable, single or array:The page says the Document Extractor converts uploaded files into text an LLM can process, because language models cannot read formats such as PDF or DOCX directly.

  2. Output layer

    Output layer: a variable named text:The node outputs a variable named text that holds the extracted raw text.

  3. Format layer

    Format layer: conversion by file type:The supported types listed include TXT, Markdown and HTML; DOCX, DOC and ODT; text-based PDFs; Excel (.xls/.xlsx) and CSV; PowerPoint (.ppt/.pptx); EML and MSG; and EPUB, VTT, JSON/YAML and Properties files.

  4. Boundary layer

    Boundary layer: binary media and long documents:The page states that files made mostly of binary content, such as images, audio and video, need specialized processing tools or external services, so the Document Extractor does not cover them.

An overview of the stages and conditions; their arrangement does not imply execution order. Follow the task steps.

Prepare the input and environment

  • An editable Dify workflow or chatflow app. The official page lists the node under Workflow & Chatflow nodes but does not explain how to create the app.
  • A model that can be used in an LLM node. The page only says the extracted text can be used in LLM prompts. It does not describe model setup and gives no API key, endpoint or SDK requirement.
  • A sample document in one of the listed formats, ideally with paragraphs and a table so order can be checked. The page gives no file size or count limit, so confirm limits in your own environment.

Mechanism and data flow

Input layer: a file variable, single or array:The page says the Document Extractor converts uploaded files into text an LLM can process, because language models cannot read formats such as PDF or DOCX directly. The node accepts a single file variable, which the page says typically comes from the Start node, or an array of files for batch processing. Choose one when you build the workflow, because it decides whether downstream nodes receive a string or an array. The page names no specific interface options and states no file limits.

Output layer: a variable named text:The node outputs a variable named text that holds the extracted raw text. A single file produces a string; multiple files produce an array[string] with one item per file's content. The page does not say whether array items follow upload order, so treat that as an expectation you must check yourself. Downstream nodes that reference text have to handle the two types separately, or an array may be used as if it were one string.

Format layer: conversion by file type:The supported types listed include TXT, Markdown and HTML; DOCX, DOC and ODT; text-based PDFs; Excel (.xls/.xlsx) and CSV; PowerPoint (.ppt/.pptx); EML and MSG; and EPUB, VTT, JSON/YAML and Properties files. Handling differs by type. Text files go through the chardet library for encoding detection with a UTF-8 fallback. Excel and CSV become Markdown tables. DOCX keeps paragraph and table ordering, with tables converted to Markdown. VTT subtitles merge consecutive utterances by the same speaker. The page says the node preserves text structure and formatting where possible.

Boundary layer: binary media and long documents:The page states that files made mostly of binary content, such as images, audio and video, need specialized processing tools or external services, so the Document Extractor does not cover them. For very large documents it advises considering the LLM's context limits and using chunking strategies if needed, but gives no threshold and no chunking method. It also says the extracted text keeps the original document's logical structure. That is the official claim, and this article has not verified any particular file.

Workflow map

Workflow stages and responsibilities
StageWhat happens
Input layerInput layer: a file variable, single or array:The page says the Document Extractor converts uploaded files into text an LLM can process, because language models cannot read formats such as PDF or DOCX directly.
Output layerOutput layer: a variable named text:The node outputs a variable named text that holds the extracted raw text.
Format layerFormat layer: conversion by file type:The supported types listed include TXT, Markdown and HTML; DOCX, DOC and ODT; text-based PDFs; Excel (.xls/.xlsx) and CSV; PowerPoint (.ppt/.pptx); EML and MSG; and EPUB, VTT, JSON/YAML and Properties files.
Boundary layerBoundary layer: binary media and long documents:The page states that files made mostly of binary content, such as images, audio and video, need specialized processing tools or external services, so the Document Extractor does not cover them.

Complete the task

Confirm the file type is supported:Start by identifying what kind of document you have. TXT, Markdown, HTML, DOCX, text-based PDF, spreadsheets, presentations and email files appear in the page's list. Images, audio and video do not, and need specialized tools or external services. Do this before building, because the type decides how extraction works and what to check later. The page says only "text-based PDFs" and does not describe scanned files, so try such a file on a small scale before putting it in a real flow.

Enable a single-file input in Start: the documented setup enables file input and passes the file to extraction. Use one DOCX and record the single-file variable name. The page does not provide exact interface labels; confirm them in your existing application. File arrays have a different output contract and are outside this configuration exercise.

Add a Document Extractor and set its input:Connect a Document Extractor after Start and point its input at the file variable from the previous step. The page says the node accepts a single file or an array for batch processing. The choice has to match the variable's shape in Start, or the output type will differ from what you expect. The page gives no error messages for a bad connection, so do not rely on specific error text to judge whether the setup is right.

Check the text type: the single-file exercise expects a string. Confirm that it matches the input before passing it to the LLM. The documented multiple-file output is array[string], shown here for comparison. The page does not specify how to process that array for an LLM; this tutorial does not treat that path as complete.

Check ordering and encoding: compare the DOCX paragraphs and tables with text, including the content represented in Markdown tables. The documentation says text files use chardet for encoding detection with a UTF-8 fallback; that does not guarantee correct decoding. Stop before passing text to the LLM if it is garbled, empty or incorrectly ordered, and inspect the original file and encoding.

Pass text to the LLM and check the answer:The last step in the official example is using the extracted text in an LLM prompt for analysis, summarization or question answering. Reference text in the prompt, then ask a question whose answer can only come from the document, and compare the reply with the source to see whether it points to the right paragraph or table. The page gives no prompt template and no conclusion about answer quality, so usability depends on your own check.

Handle long documents and clean up:For a long document, look at the chosen LLM's context limit first and split the text into chunks if needed. The page offers only this advice and no chunking recipe. It also covers no cleanup, so any workflow, uploaded sample file or temporary variable you created for practice should be deleted or kept according to the rules of your environment. Do not leave files with sensitive content in a shared app.

Worked example

The official page gives a ChatPDF-style document Q&A workflow. File input is enabled in the Start node, the Document Extractor extracts text, and the LLM uses that text for analysis, summarization or question answering, while the user uploads a document and asks questions in the chat interface. What follows is a hypothetical check built on that path. It is not the official example's data and not an observation from this batch. Imagine uploading a DOCX with a paragraph of description, a table and a paragraph of conclusions. Based on the page, text is expected to be a string with the table in Markdown between the two paragraphs. If two documents are uploaded together, the expected result is an array[string] with two items. Then ask the LLM about one row of the table and compare its answer with the source. All of these results are expectations, and none was run.

Check the result and failure paths

  • Success: for one file text is a string, for several files it is an array[string], and the item count matches the number of uploaded files.
  • Success: in DOCX output the paragraphs and table appear in the original order with the table in Markdown form; Excel and CSV come out as Markdown tables.
  • Success: the LLM's answer to a document question can be found in the source rather than supplied from nowhere.
  • Scope check: images, audio and video need specialized tools or external services and are outside this text-extraction path. This tutorial does not infer the error or output produced by uploading them.
  • Acceptance check: inspect the type, context length and source support. Stop delivery if the type is wrong, context is insufficient or an answer lacks support. Record and correct the issue before checking again; do not assume a specific error.

If you cancel the exercise, stop subsequent runs and handle sample resources under your environment rules. Stopping does not establish that uploaded data was deleted. Extraction errors or failed acceptance also stop the question-answering path. These are editorial operating suggestions.

Scope and limits

  • This article covers converting uploaded documents to text and checking structure. It does not cover knowledge base retrieval, indexing or parameter extraction.
  • The page gives no file size or count limits, version support, pricing, login conditions or API call method, and this article draws no inferences about them.
  • The page says extracted text keeps the original logical structure. That is the official description, and whether a given file matches exactly is for you to check.
  • Cases the page does not address, such as scanned or image-based PDFs, must not be treated as supported.

No Dify node or API was run, no file was uploaded and no output was observed. Capabilities and types come from s1; the sample, manual checks, stopping conditions and resource-handling suggestions are editorial guidance.

Article sources

Original editorial content; official descriptions and checking suggestions are distinguished.

  1. Dify · Official sources
    View details