Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Charts 5.2.4 Minor update available for module charts (5.2.4). Release: Tagify 2.0.3 Minor update available for module tagify (2.0.3). Release: Tagify 1.2.54 Minor update available for module tagify (1.2.54). Release: ECA: Event - Condition - Action 3.1.8 Minor update available for module eca (3.1.8). Release: GoogleTag Manager 2.0.5 Minor update available for module gtm (2.0.5). Release: GoogleTag Manager 2.0.4 Minor update available for module gtm (2.0.4). Release: X-Frame-Options Allow-From webvisor.com 2.0.4 Minor update available for module xframe_allow_webvisor (2.0.4). Release: Commerce ML Starter 2.0.5 Minor update available for module cmlstarter (2.0.5). Usage Milestone: Easy Email Module easy_email crossed 10,000 active installs. Security Coverage: Menu Link By Default Module menu_link_by_default now has official Drupal security advisory coverage.

AI Text Cleaner

4 sites No security coverage Drupal 10–11

Part of the AI ecosystem · 302 projects

View on drupal.org

This module offers a text filter and a Drush command to clean up formatting issues common in AI-generated text. It can remove extra characters, normalize spacing and punctuation, and strip markdown elements, either automatically when content is saved or in bulk via Drush.

AI Text Cleaner

AI Text Cleaner is a small Drupal module that provides a text filter and a Drush command to clean formatting quirks from ChatGPT or other LLM outputs.
It removes hidden or problematic characters, converts non-breaking spaces, normalizes dashes and quotes, converts ellipses, and strips Markdown-style headings and stray asterisks.

Features

  • Text filter plugin that can be enabled on input formats to clean content on save.
  • Options supported:
    • Remove hidden/control characters
    • Convert non-breaking spaces to regular spaces
    • Normalize dashes (hyphen/en dash/em dash) to a standard hyphen
    • Normalize quotes (curly “smart” quotes → straight quotes)
    • Convert ellipses (…) to three periods (...)
    • Remove trailing whitespace
    • Remove stray asterisks and stray list artifacts
    • Strip Markdown-style headings (leading # characters)
  • Drush command ai:text-clean (alias ai-text-clean) to run the cleaner across nodes in bulk.
  • Per-option statistics exported for reporting or CSV-like table output.
  • Analysis mode (dry run) that reports what would change without saving.
  • Ability to limit by content type (bundle), language, and maximum node count.

Dependencies

  • Drupal core (module developed for Drupal 11)
  • PHP 8.1 or newer
  • Optional: Drush (to use the ai:text-clean command)
  • Filter system: integrates with Drupal's core filter subsystem (ensure input formats are configured).

Installation

  1. Place the module in web/modules/custom/ai_text_cleaner.
  2. Enable the module (example using Drush):
drush en ai_text_cleaner -y

To automatically apply the filter, go to Configuration → Text formats and editors, edit the target input format, and enable the "AI Text Cleaner" filter at the desired weight.

Plain-text field cleaning (since v1.1)

A new configuration option allows the module to clean simple text fields (fields without an assigned Text Format) when content is saved. To enable and configure this:

  1. Go to Administration → Configuration → Content → AI Text Cleaner settings (or visit /admin/config/content/ai-text-cleaner).
  2. Enable "Clean plain text fields" and choose which cleaning options to apply to plain text fields.

When enabled, the same cleaning rules that the filter uses for formatted text (remove hidden characters, normalize dashes/quotes/guillemets, convert ellipses, etc.) will be applied to fields that don't have a text format set.

Usage with Drush

Analyze (dry run) all nodes of type article:

drush ai:text-clean --types=article --analysis=TRUE

Apply cleaning and save changes for up to 50 nodes across all languages:

drush ai:text-clean --limit=50 --analysis=FALSE

You can supply multiple content types or languages as comma-separated lists, for example --types=article,page or --languages=en,de.

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
Mar 2026
Latest release
5 months ago
Releases (12 mo)
4 ▲ from 0
Maintenance
Active

Release Timeline

Releases

Version Type Core Release date
1.1.0 Stable 10–11 Apr 4, 2026
1.1.0-rc1 Pre-release 10–11 Apr 2, 2026
1.0.1 Stable 10–11 Mar 14, 2026
1.0.0 Stable 10–11 Mar 14, 2026