How to remove all terms from a taxonomy

You may need to delete all the terms of a taxonomy, either to replace them with a new list of terms, or under development to redo an import.

Delete terms with a Drush command

When there are a lot of terms, it can be quite cumbersome to do from the back office. There is a very simple Drush command that allows you to remove all terms:

on Drupal 8 or 9, run this command:

Commande Drush

drush entity:delete taxonomy_term --bundle=VOCABULARY_ID

 

Replace VOCABULARY_ID with the machine name of the taxonomy vocabulary.

Example with a "Nationality" vocabulary with a machine name nationality.

drush entity:delete taxonomy_term --bundle=nationalite

 

The command returns the ids of the deleted terms

[success] Deleted taxonomy_term entity Ids: 201, 202, 203, 204, 205

 

Other useful resources

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.