How can I get the existing content type list with drush? This will allow me to quickly produce a list.

I've tried with:

$ drush @d6 @sites genc --types

But I need the devel_generates module enabled for this.

Command genc needs the following module(s) enabled to run: devel_generate.


6 Answers 6


Try the following commands.

Drupal 7 & 8

drush ev "print_r(array_keys(node_type_get_types()));"

Drupal 5 & 6

drush ev "print_r(array_keys(node_get_types()));"

List of names:

drush sqlq "SELECT name FROM node_type;"

List of machine names:

drush sqlq "SELECT type FROM node_type;"

This works in D6 and D7.

The first line of the command's output will be name or type, respectively. Pipe |tail -n +2 if you want to drop that first line.

  • trying but get errors: $ drush @d6mg sqlq "SELECT type FROM node_type;" ERROR 1146 (42S02) at line 1: Table 'drupal6_mg.node_type' doesn't exist $ drush @d6mg sqlq "SELECT name FROM node_type;" ERROR 1146 (42S02) at line 1: Table 'drupal6_mg.node_type' doesn't exist Jan 6, 2014 at 11:16
  • 1
    @webmaster_pf, I just checked this again, works fine. Do you have a table_prefix on this site? What does drush sqlq "SHOW TABLES;"|grep type give you?
    – the
    Jan 9, 2015 at 22:01
  • yes i have prefix but your command give me a list of tables .this is the right command :drush sqlq "SHOW TABLES;"|grep content_type Jan 23, 2015 at 9:27

You can create a drush command named content-type-list. Create a module named drush_content_types, inside the drush_content_types.drush.inc file put this code:

 * @file
 * Drush commands related to Content Types.

* Implements hook_drush_command().
function drush_content_types_drush_command() {
  $items['content-type-list'] = array(
    'description' => dt("Show a list of available content types."),
    'aliases' => array('ctl'),
  return $items;

 * Callback for the content-type-list command.
function drush_drush_content_types_content_type_list() {
  $content_types = array_keys(node_type_get_types());

  drush_print(dt("Machine name"));
  drush_print(implode("\r\n", $content_types));

Install the module, run drush cc drush to clear the drush cache and use the command like this:

drush ctl


drush content-type-list

If you want add another alias to the command add elements to the aliases array like this:

'aliases' => array('ctl', 'all-content-types', 'act'),

And you can use this commands:

drush act
drush all-content-types
drush ctl
drush content-type-list

Always the output will be:

Machine name:
content 1
content 2
content n

If you know how to do it in Drupal, you just need to use drush eval:

Drupal 6:

drush eval '$types = node_get_types(); foreach($types as $type => $object) { print $type . "\n"; }'

Drupal 7:

drush eval '$types = node_type_get_types(); foreach($types as $type => $object) { print $type . "\n"; }'

See this list of drush commands for other useful examples using eval.


Dupal 9:

drush ev "print_r(array_keys(\Drupal\node\Entity\NodeType::loadMultiple()));"

For a more rich, complete, report, you can use site_audit, which will give you content types, fields, and a ton of extra information


Drutiny is as well a good tool, not necessarily for content types, but in order to get a ton of extra information from your site


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.