Things getting messy in the technical world of Drupal is quite common. Whether it’s migration leftovers, abandoned drafts, or test content from staging, things easily pile up in the background, making it challenging for the content admin.

Your workflow slows down, and teams need more time to clean things up. And although Drupal’s content page is powerful, a quick, bulk cleanup at scale can be a huge time saver!

That’s where Node Cleanup comes in.

Node Cleanup is a lightweight tool designed for Drupal 10/11 to help remove unpublished content easily. In this blog, I shall walk you through this contributed module, why you need it, the problems it solves for you, and how it works.

What is Node Cleanup?

Node Cleanup is a contributed  admin tool that allows site administrators to:

  • Filter nodes by Content Type
  • Filter by Published / Unpublished Status
  • View nodes in a structured admin table
  • Bulk delete only unpublished nodes

The module is:

  • Simple and lightweight
  • Built using Drupal 10/11 best practices
  • Dependency-injection compliant
  • Focused on performance and simplicity

Why do you need this module

In real-world Drupal environments, you’ll often encounter:

  • Migration projects leaving behind unused nodes
  • Editors creating drafts that are never published
  • Staging/UAT environments filled with test content
  • Old unpublished content remaining in the database
  • Time-consuming manual cleanup from the default Content page

While Drupal’s core Content listing works well, it isn’t optimized for bulk cleanup operations.

Node Cleanup provides a dedicated, focused interface for fast and safe content cleanup.

Where does it appear?

The module integrates seamlessly into the admin UI:

Admin/Content/Node Cleanup

It extends the core content administration area without altering existing workflows.

What problem does it solve?

On large Drupal sites, content clutter becomes a serious maintenance issue:

  • Drafts pile up
  • Test nodes remain forgotten
  • Migration leftovers increase the database size
  • Admin time is wasted on repetitive deletion tasks

Node Cleanup solves this by offering a centralized interface to:

✔ Filter nodes by content type
✔ Filter by published/unpublished status
✔ View results in a structured table select format
✔ Delete multiple unpublished nodes safely

How it works (Technical Overview)

1. Uses Entity Query API (Not Direct SQL)

The module retrieves nodes using Drupal’s Entity Query API, ensuring:

$query = $this->entityTypeManager
 ->getStorage('node')
 ->getQuery()
 ->accessCheck(FALSE);

This avoids raw database queries and keeps the module clean and maintainable.

2. Dynamic Content Type Loading

All content types are loaded dynamically using the Entity Type Manager.

  • Default content types
  • Custom bundles
  • Future content types

3. Tableselect Interface for Bulk Operations

Nodes are displayed using Drupal’s #tableselect form element, giving administrators:

  • Linked node titles
  • Bundle information
  • Status display
  • Multi-select checkboxes

This ensures a native and familiar Drupal admin experience.

4. Safe Deletion Logic

The most important feature:

Only unpublished nodes are deleted.

Even if a published node is selected accidentally, it will not be removed.

if (!$node->isPublished()) {
 $node->delete();
}

This safety guard prevents accidental content loss.

How it looks in the Admin UI

Below is how you would see the admin UI of the Node Cleanup module once you implement it in your workflow:

 

Final thoughts

Cleaning up cluttered content need not be a hassle anymore. With the Node Cleanup module, content admins can rest easy. This simple yet powerful administrative utility for Drupal 10 and 11 helps improve content hygiene, save admin time, and prevent accidental deletions, all while following Drupal coding best practices.

If your Drupal site accumulates unpublished content regularly, this module is a practical and efficient solution.

Contact us

LET'S DISCUSS YOUR IDEAS. 
WE'D LOVE TO HEAR FROM YOU.

CONTACT US SUBMIT RFP