Drupal is a registered trademark of Dries Buytaert
Release: reCAPTCHA 8.x-3.5 Minor update available for module recaptcha (8.x-3.5). Release: Search API Solr 4.3.14 Minor update available for module search_api_solr (4.3.14). Release: ECA: Event - Condition - Action 2.1.22 Minor update available for module eca (2.1.22). Release: WebProfiler 11.2.1 Minor update available for module webprofiler (11.2.1). Usage Milestone: Entity Browser Module entity_browser crossed 100,000 active installs. Release: Editoria11y SI (SiteImprove) 3.0.0 Major update available for module editoria11y_si (3.0.0). Release: Diagnosis 1.0.3 Minor update available for theme diagnosis (1.0.3). Release: DiBa Integration 1.3.3 Minor update available for module diba_integration (1.3.3). Release: AlternativeCommerce NovaPoshta API 1.1.10 Minor update available for module basket_novaposhta (1.1.10). Module Revived: Commerce Currency Resolver 2.0.2 Module commerce_currency_resolver updated after 10 months of inactivity (2.0.2).

This module automatically extracts content from uploaded documents like Word, PDF, and spreadsheets, converting it into plain text, HTML, Markdown, or structured JSON. It runs entirely on your server using PHP and can be integrated with other Drupal AI modules for automated text extraction and AI agent functionality.

AI File to Text automatically extracts content from uploaded document files and converts them to plain text, HTML, Markdown, or structured JSON. Built on an extensible extractor architecture, it integrates with the Drupal AI module and Document Loader module — providing AI Automator plugins, AI Agent function calls, and a Document Loader plugin as three consumers that all flow through the same extraction pipeline. No external services, APIs, or server-side applications required. Everything runs in pure PHP on your server.

Features

  • 10 file extensions supported out of the box across 7 extractors: Word (.docx, .doc), OpenDocument (.odt), PDF (.pdf), Spreadsheets (.xlsx, .xls, .ods, .csv), Plain Text (.txt), and Markdown (.md).
  • 4 output formats: plain text, styled HTML, Markdown, or structured JSON.
  • HTML output preserves headings, bold, italic, underline, font sizes, colors, links, lists, and tables.
  • JSON output produces a structured DOM tree ({"tag": "p", "attributes": {...}, "children": [...]}) for non-tabular files, or an array of objects keyed by column headers for spreadsheets/CSV.
  • Document Loader plugin (document_loader:file) — enables any third-party code to load documents programmatically via the Document Loader API.
  • AI Automator plugins for text_long and string_long fields — upload a file and the text is extracted automatically on entity save.
  • AI Agent function call (file_to_text) — AI agents can read and process documents autonomously.
  • Extensible architecture — other modules can register new file-type extractors as tagged services without modifying this module.
  • Dynamic type registration — extractor types and output capabilities are automatically discovered and registered with the Document Loader plugin system.
  • Per-type output accuracy — when extractors have different output capabilities, plugin definitions are automatically split into capability groups so that getLoaderByType() returns accurate results (no false positives).
  • No external services, APIs, or server-side applications required.

Architecture

All consumers go through a single unified path:

Consumers (Automator / FunctionCall / Document Loader API)
  └─ FileDocumentLoader  (document_loader plugin)
       └─ FileExtractorManager  (routes by file extension)
            └─ Extractors  (auto-discovered tagged services)

Installation

For DDEV environments with Poppler support, add to .ddev/config.yaml:

webimage_extra_packages:
  - poppler-utils

Extending — Adding Custom Extractors

Other modules can add support for new file types by:
See the module's README.md for a full extractor implementation example.

Requirements

PHP libraries (installed automatically via Composer):

Optional system package for improved PDF extraction:

  • poppler-utils — When installed, the module uses pdftohtml for higher-quality PDF output with better table, link, and style detection. Falls back to smalot/pdfparser if not available.

Recommended modules

  • AI Agents — Enables AI agent workflows where agents can call file_to_text to read and process uploaded documents autonomously.
  • AI Context — Provides additional context to AI operations, useful when combining file extraction with other AI tasks.

Similar projects

  • AI Simple PDF to Text — Handles PDF files, converts to plain text only.
  • Unstructured — Supports a similar range of file types but requires an external Unstructured API server or a SaaS account.

Supporting this Module

Contributions, bug reports, and feature requests are welcome in the issue queue.

Community Documentation

Documentation, architecture details, and usage examples are included in the module's README.md file.

Activity

Tracked releases
2
Tracked since
Feb 2026
Latest release
2 months ago
Releases (12 mo)
2 ▲ from 0
Maintenance
Active

Releases

Version Type Release date
1.0.0 Stable May 31, 2026
1.0.x-dev Dev Feb 11, 2026