extract_text

extract_text returns the plain text of a document — all of it, or one page with page. The starting point for “what does this say?” across PDF, Office, email, e-book and 50+ other formats. Example prompt: “Extract the text from page 2 of contract.docx.”

Tool description (as the AI agent sees it):

Extracts plain text from a document file. Supports PDF, DOCX, XLSX, PPTX, TXT, HTML, CSV, EML, MSG, RTF, ODT, EPUB, and 50+ more formats. Call this tool immediately whenever the user asks to extract text, read text, or get the content of a document. Do NOT pre-check whether files exist — just pass the filename the user provided. Returns the document’s plain text (truncated with a marker if it exceeds the configured budget). On failure, the response text starts with ‘Text extraction failed for’ followed by the underlying exception type, message, and inner-exception chain.

Parameters

NameTypeRequiredDescription
fileobjectyes— FileInput shape
passwordstringnoPassword for protected documents
pageintegernoPage number to extract from (1-based). Omit for all pages.

Example call

{
  "name": "extract_text",
  "arguments": {
    "file": {
      "filePath": "contract.docx"
    },
    "page": 2
  }
}

Result

The document’s plain text. Very large outputs are truncated with a marker showing where it stopped — so ask for a specific page when you need a complete read of a long document, and loop over pages rather than requesting everything at once.

On a scanned document this returns little or nothing: there is no text layer to read, and no OCR step. That is a true answer about the file, not a failure — check with get_document_info and, for codes on the page, extract_barcodes.

On failure the text starts with Text extraction failed for, followed by the exception type and message.

Example prompts

  • “Extract the text from page 2 of contract.docx.”
  • “What does this email say?”
  • “Pull the text out of these PDFs and summarize each one.”
  • “Get the content of page 12 — I only need that section.”

See it used end-to-end: Extract document data with AI agents.