Backend and Infrastructure

Overview: Drush's Output Formatting System for Drupal 8, 9, and 10

Some Drush commands return a lot of information -- lists of modules, generators, and status reports, for example. It might be hard to find a property you need in the small command window output. Luckily, the output of Drush commands can be piped to other commands, used as a source for imports, settings for CI, and other DevOps tasks.

In order to accommodate all these different use cases, Drush comes with a formatting system that allows you to format and filter output to meet your needs. This system allows to you specify what fields you want returned when the output contains more than one field. It also allows Drush command output to be formatted as JSON, XML, raw PHP, a table, and more.

In this tutorial we'll:

  • Learn how to specify the output format -- and what formats are available
  • Limit the fields that are returned in a report
  • Learn to filter the output to only the data we're interested in

By the end of this tutorial you'll know how to format a Drush command's output to fit your needs.