As a Drupal site grows in complexity, maintaining clear documentation of your active extensions becomes essential. Whether you are performing a security audit, preparing for a major version migration, or simply onboarding a new developer, you often need a clean list of every enabled module on your system.
While the standard administrative interface at admin/modules provides a visual overview, it isn't always the most efficient way to export data for documentation. In this guide, we will explore five different ways to retrieve a list of active modules, ranging from command-line tools to custom database queries.
1. Using Drush (The Professional Standard)
If you have command-line access, Drush is the fastest and most reliable method to audit your modules. The pm-list (or pml) command is designed specifically for this purpose.
To get a simple list of all enabled modules, run:
drush pm-list --type=Module --status=enabled
Filtering for Contributed and Custom Modules
Often, you don't need to see the Core modules because they are standard across all installations. To exclude core and focus only on what you've added to the site, use the --no-core flag:
drush pm-list --type=Module --no-core --status=enabled
If you need a machine-readable list to use in a script or a makefile, you can add the --pipe flag to return a space-delimited string of module machine names.
2. Querying the Database Directly
Sometimes you may have access to the database (via phpMyAdmin or a MySQL client) but not the file system or Drush. In Drupal 7, module status is stored in the system table. You can run a quick SQL query to pull the names of all active modules:
SELECT name FROM system WHERE type = 'module' AND status = 1 ORDER BY name ASC;
If you want to run this through a quick PHP snippet or a Drush script, you can use the following code:
$enabled_modules = db_query("SELECT name FROM {system} WHERE type = 'module' AND status = 1")->fetchCol('name');
print implode("\n", $enabled_modules);
3. Custom PHP Scripts for Detailed Audits
For a more detailed report—such as distinguishing between Core, Contrib, and Custom modules—you can use Drupal's internal API. The following script can be placed in your document root (e.g., modules_audit.php) and executed via drush scr modules_audit.php or through a protected web URL.
<?php
$files = system_rebuild_module_data();
$modules_list = [];
foreach ($files as $filename => $file) {
// Hidden modules and Themes will be excluded.
if (!empty($file->info['hidden']) || $file->type != 'module') {
continue;
}
// Get module type based on path.
$type = 'Contrib';
if ($file->info['package'] == 'Core') {
$type = 'Core';
}
elseif (strpos($file->uri, "sites/all/modules/custom/") !== false) {
$type = 'Custom';
}
// Check if module is enabled.
if ($file->status) {
$modules_list[$type]['enabled'][] = $file->name;
}
else {
$modules_list[$type]['disabled'][] = $file->name;
}
}
foreach ($modules_list as $type => $info) {
echo "$type Modules:\n";
echo "Enabled: " . implode(', ', $info['enabled']) . "\n\n";
}
4. Leveraging Contributed Modules
If you prefer a GUI-based solution that provides better reporting than the core Modules page, several contributed modules can help:
- Module Filter: While it doesn't create a list for export, it significantly improves the
admin/modulesUI, allowing you to filter by status and package instantly. - Enabled Modules: This is a lightweight module specifically designed to provide a simple list of all active modules on a dedicated page.
- Forena Reports: For enterprise-level documentation, Forena allows you to create custom reports based on the Drupal database. You can use a simple
.FRXreport to list modules:
<div frx:block="drupal/enabled_modules" id="forena-1">
<table>
<thead>
<tr>
<th>Name</th>
<th>Owner</th>
</tr>
</thead>
<tbody>
<tr frx:foreach="*" id="forena-2">
<td>{name}</td>
<td>{owner}</td>
</tr>
</tbody>
</table>
</div>
5. The Browser Console "Hack"
If you are in a pinch and have no Drush or FTP access, but you are logged in as an administrator, you can use the browser's JavaScript console. Navigate to admin/modules, open your browser inspector (F12), and paste this jQuery snippet:
jQuery('table.sticky-enabled input[checked=checked]')
.closest('tr')
.find('td label strong')
.each(function() {
console.log(jQuery(this).text());
});
This will scrape the labels of all checked (enabled) modules directly from the page and print them in your console for easy copying.
Wrapping Up
Knowing exactly what is running on your Drupal site is the first step toward a healthy maintenance routine. For most developers, Drush remains the gold standard for speed and accuracy. However, if you are building a custom dashboard or need a formatted report for a client, using SQL queries or the Forena module provides the flexibility you need.
Note on Versioning: While the examples above are tailored for Drupal 7, the Drush commands and general logic remain highly relevant for modern Drupal (9/10/11), though internal API functions like system_rebuild_module_data() have been replaced by Service containers in newer versions.