Drupal is a registered trademark of Dries Buytaert
Release: Leaflet 10.4.11 Minor update available for module leaflet (10.4.11). Release: Session Inspector 1.0.8 Minor update available for module session_inspector (1.0.8). Release: Migrate QA 2.0.4 Minor update available for module migrate_qa (2.0.4). Release: CKEditor Description List 3.0.0 Major update available for module ckeditor_descriptionlist (3.0.0). Release: FlowDrop 2.4.0 Minor update available for module flowdrop (2.4.0). Release: JWT Token Refresh 1.0.4 Minor update available for module jwt_token_refresh (1.0.4). Release: ConReg 1.0.0-beta1 First beta version released for module conreg (1.0.0-beta1). Release: AI Image Studio 1.0.0-beta8 New beta version released for module ai_image_studio (1.0.0-beta8). Usage Milestone: Statistics Counter Module statistics_counter crossed 1,000 active installs. Module Revived: Decoupled Router 2.0.7 Module decoupled_router updated after 11 months of inactivity (2.0.7).

This module converts HTML content from one field into Markdown in another field. It removes unnecessary HTML tags and converts elements like tables, headings, and lists into their Markdown equivalents, significantly reducing token count for AI processing.

Reads the HTML in one field and writes it into another field as Markdown. Markdown holds the same text in far fewer tokens, so it costs less to send to a model.

Why HTML to markdown for Automators?

A model that reads HTML pays for every tag, every attribute and every class name. None of that carries meaning for the model. On a EUR-Lex notice the same document is 239,452 characters as HTML and 73,430 characters as Markdown, a drop of 69%.

The source can be any field that holds HTML: a body field, a WYSIWYG field, the output of a crawler, or imported content. This module knows nothing about where the HTML came from.

What the conversion does

  • script, style and noscript are removed
  • Tables become Markdown pipe tables
  • Headings, lists, links, bold and italic keep their meaning
  • A tag with no Markdown equivalent loses the tag and keeps its text
  • The input is read as UTF-8, so accented characters survive

Requirements

  • Drupal 10.4+ / 11.x / 12.x
  • AI ^1.4, with the ai_automators submodule enabled
  • One field that holds HTML, and one field for the Markdown

How to use

  1. Add a field for the Markdown. A plain long text field keeps the Markdown intact. A formatted long text field also works.
  2. Open the settings of this field.
  3. Enable the AI Automator and select HTML to Markdown.
  4. Set the base field to the field that holds the HTML.
  5. Give this automator a higher weight than the automator that fills the HTML field, so it runs after it.

An automator cannot write into its own base field, so the HTML field and the Markdown field must be two different fields.

Selector

The module has one setting. Leave it empty to convert the whole field, or give one CSS selector to convert only a part of it.

Selector Result (empty) The whole field #document1 The content of the element with id document1 div.content The content of every div with class content main article The content of every article inside main

The module returns the content inside each match, not the match itself. When the selector matches more than one element, the parts are joined in document order. When the selector matches nothing, or when the selector is not valid, the field stays empty.

Allowed source fields

text_long, text_with_summary, text, string_long and string.

Related

Activity

Tracked releases
2
Tracked since
Aug 2026
Latest release
4 days ago
Releases (12 mo)
2 ▲ from 0
Maintenance
Active

Releases

Version Type Release date
1.0.0 Stable Aug 19, 2026
1.0.x-dev Dev Aug 18, 2026