Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Release: Opensolr Search 4.5.0 Minor update available for module opensolr_search (4.5.0). Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Usage Milestone: Simplify Module simplify crossed 10,000 active installs. Usage Milestone: Views Reference Filter Module entityreference_filter crossed 10,000 active installs. Usage Milestone: Dropdown Language Module dropdown_language crossed 10,000 active installs. Usage Milestone: Paragraphs Browser Module paragraphs_browser crossed 10,000 active installs. Usage Milestone: OpenAPI Module openapi crossed 10,000 active installs. Usage Milestone: Decoupled Router Module decoupled_router crossed 10,000 active installs. Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

This module processes raw HTML strings to prepare them for AI systems, search indexes, or data migration. It cleans up HTML by removing unwanted elements like scripts and ads, converts relative links to absolute ones, and can optionally fetch HTML directly from a URL. The processed HTML is then minified and can be wrapped in a full document structure, resulting in cleaner, more targeted content.

What it does

Accepts an HTML string and runs it through the html_processor module's pipeline. Returns clean, narrowed HTML ready for AI systems, search indexes, or data migration.

  • Extracts specific content regions using CSS selectors (e.g. main, article, .content-body)
  • Strips unwanted markup via regex patterns (scripts, comments, tracking pixels)
  • Removes advertising elements — Google AdSense, DoubleClick, Taboola, Outbrain, Media.net, or custom patterns
  • Rewrites relative href and src attributes to absolute URLs using a caller-supplied base URL
  • Sanitizes HTML with Symfony HtmlSanitizer — configurable element and attribute allowlists, or use the safe/static shorthands
  • Wraps output in a full HTML document structure when needed
  • Minifies whitespace to reduce token count for AI pipelines

The base module processes HTML you already have in memory. For fetching HTML directly from a URL, see the URL submodule below.

URL submodule (opt-in)

document_loader_html_processor_url ships inside this package and is disabled by default. Enable it when you need the server to fetch a URL and run the returned HTML through the pipeline.

  • Fetches a URL with a single GET request via Drupal's http_client
  • Auto-injects the fetched URL as base_url so relative links resolve without extra configuration
  • Guards: scheme allowlist (http/https only), content-type check, 10 MB response cap, bounded streaming read, redirect protocol pinning, and credential-safe error messages

See the URL submodule's README.md for full security considerations and known SSRF limitations.

Use cases

  • Prepare web content for ingestion into an AI or RAG pipeline
  • Normalize HTML before search indexing
  • Extract and sanitize article bodies from scraped or migrated HTML
  • Strip ads and tracking from content before storage or republication

Requirements

This module's major version tracks Document Loader's major version — 2.x of this module requires Document Loader 2.x, 3.x will require Document Loader 3.x, and so on.

Recommended modules

  • document_loader_html_processor_url — included in this package; enable for URL fetching

Installation

composer require drupal/html_processor drupal/document_loader_html_processor

Enable at Administration > Extend. To also enable URL fetching:

drush en document_loader_html_processor_url

Configuration

The plugin appears at Administration > Configuration > Media > Document Loader. There is no per-plugin admin form — all processing options are passed programmatically.

use Drupal\document_loader_html_processor\DocumentLoaderType\Input\HtmlContentInput;

$loader = \Drupal::service('plugin.manager.document_loader')
  ->createInstance('document_loader_html_processor.html_processor');

$input = new HtmlContentInput($html, [
  'container'  => 'article',
  'remove_ads' => TRUE,
  'sanitizer'  => 'safe',
  'base_url'   => 'https://example.com/page',
]);

$processed = $loader->load($input, 'html')->getContent();

See README.md for the full options reference.

Good to know

  • No URL fetching in the base module. Pass resolved HTML via HtmlContentInput. Enable the URL submodule only when you want this module to make outbound HTTP requests.
  • No admin UI. Configuration is entirely code-driven — there are no forms to fill in.
  • SSRF limitation. The URL submodule does not filter private or internal IP ranges. Mitigate at the infrastructure layer (egress firewall, forward proxy) before exposing it to untrusted callers. See the URL submodule's README.md for details.
  • Versioning follows Document Loader. The major version of this module always matches the required major version of Document Loader.
  • Security advisory coverage. This project is not covered by Drupal's security advisory policy.

Similar projects

  • Document Loader Webpage — Readability extraction and Markdown output, not just HTML cleaning
  • HTML Processor — the standalone service module this bridge delegates to; use it directly if you do not need the Document Loader plugin layer

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
4
Tracked since
Feb 2026
Latest release
1 month ago
Releases (12 mo)
4 ▲ from 0
Maintenance
Active

Release Timeline

Releases

Version Type Core Release date
2.0.0-rc2 Pre-release 10–11 Jul 1, 2026
2.0.0-rc1 Pre-release 10–11 Jun 30, 2026
1.0.0-rc1 Pre-release 10–11 Feb 24, 2026
1.0.x-dev Dev 10–11 Feb 24, 2026