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.

  • the easiest way is to open admin/structure/types
    – xurshid29
    Commented Dec 18, 2013 at 8:43
  • 1
    Why don't you enable it then?
    – Mołot
    Commented Dec 18, 2013 at 8:45
  • because this module doesn't give a list of content types..actually i do it by copy/paste list from admin/content/types/list
    – user8753
    Commented Dec 18, 2013 at 9:00
  • genc is used from devel_generate to generate new content, this wont show you existing content types. Commented Dec 18, 2013 at 9:06
  • there is this function: api.drupal.org/api/drupal/modules!node!node.module/function/… Commented Dec 18, 2013 at 9:09

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
    – user8753
    Commented 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
    Commented 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
    – user8753
    Commented 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.


Drupal 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 and acknowledge you have read our privacy policy.