diff --git a/commands/core/core.drush.inc b/commands/core/core.drush.inc
old mode 100644
new mode 100755
index 130bc00..6f92cd7
--- a/commands/core/core.drush.inc
+++ b/commands/core/core.drush.inc
@@ -1151,3 +1151,23 @@ function drush_core_execute() {
   // Must be a local command.
   return drush_shell_proc_open($cmd);
 }
+
+/**
+ * Implements hook_drush_output_formats().
+ */
+function core_drush_output_formats() {
+  $formats['export'] = array(
+    'label' => dt("Export"),
+    'callback' => 'drush_output_format_export',
+  );
+  $formats['json'] = array(
+    'label' => dt("Json"),
+    'callback' => 'drush_output_format_json',
+  );
+  $formats['print_r'] = array(
+    'label' => dt("print_r"),
+    'callback' => 'drush_format_print_r',
+  );
+
+  return $formats;
+}
diff --git a/docs/drush.api.php b/docs/drush.api.php
old mode 100644
new mode 100755
index 50e5c96..da29e8e
--- a/docs/drush.api.php
+++ b/docs/drush.api.php
@@ -318,3 +318,23 @@ function hook_drush_engine_ENGINE_TYPE() {
 /**
  * @} End of "addtogroup hooks".
  */
+
+/**
+ * Register format types with drush to be used by drush_format().
+ *
+ * - 'label' - The format label.
+ * _ 'callback' - The callback function to be used to process this format.
+ *   This function is passed $input (string to be formatted) and $label.
+ *   @see core_drush_output_formats() and related callback functions in output.inc file.
+ *
+ * @see drush_format().
+ *
+ */
+function hook_drush_output_formats() {
+  $formats['print_r'] = array(
+    'label' => dt("print_r"),
+    'callback' => 'drush_print_r',
+  );
+
+  return $formats;
+}
diff --git a/includes/output.inc b/includes/output.inc
old mode 100644
new mode 100755
index f036e34..f192c20
--- a/includes/output.inc
+++ b/includes/output.inc
@@ -79,46 +79,78 @@ function drush_print_r($array, $handle = NULL) {
  *   The variable formatted according to specified format. Ready for drush_print().
  */
 function drush_format($input, $label = NULL, $format = NULL) {
+  $formats = drush_command_invoke_all('drush_output_formats');
+
   if (is_null(($format))) {
     $format = drush_get_option('format', 'print_r');
   }
-  if ($format != 'export') {
-    if ($input === TRUE) {
-      $input = 'TRUE';
-    }
-    elseif ($input === FALSE) {
-      $input = 'FALSE';
+
+  // Contruct the output as defined by the formatter.
+  if (isset($formats[$format]['callback']) && function_exists($formats[$format]['callback'])) {
+    $function = $formats[$format]['callback'];
+  }
+  else {
+    // Display the formatter error only once.
+    static $error = FALSE;
+    if (!$error) {
+      drush_set_error('DRUSH_FORMAT_NOT_FOUND',
+        dt("Format !format not found. Using 'print_r' instead.", array('!format' => $format)));
+      $error = TRUE;
     }
+    $function = $formats['print_r']['callback'];
   }
 
-  switch ($format) {
-    case 'export':
-      if ($label) {
-        $output = "\$variables['$label'] = " . var_export($input, TRUE) . ';';
-      }
-      else {
-        $output = var_export($input, TRUE);
-      }
-      break;
-    case 'json':
-      $output = drush_json_encode($input);
-      break;
-    case 'print_r':
-    default:
-      if (is_string($input)) {
-        $input = '"' . $input . '"';
-      }
-      elseif (is_array($input) || is_object($input)) {
-        $input = print_r($input, TRUE);
-      }
+  return $function($input, $label);
+}
 
-      if ($label) {
-        $input = $label . ': ' . $input;
-      }
-      $output = $input;
-      break;
+/**
+ * return an array of available formats.
+ */
+function drush_format_get_formats() {
+  $formats = drush_command_invoke_all('drush_output_formats');
+  return array_keys($formats);
+}
+
+/**
+ * Prints an array or string.
+ * @param $array
+ *   The array to print.
+ */
+function drush_format_print_r($input, $label = NULL) {
+  if ($label) {
+    $input = array($label => $input);
+  }
+  return print_r($input, TRUE);
+}
+
+/**
+ * Formats variables using var_export.
+ */
+function drush_output_format_export($input, $label = NULL) {
+  if ($input === TRUE) {
+    $input = 'TRUE';
+  }
+  elseif ($input === FALSE) {
+    $input = 'FALSE';
+  }
+
+  if ($label) {
+    return "\$variables['$label'] = " . var_export($input, TRUE) . ';';
+  }
+  else {
+    return var_export($input, TRUE);
+  }
+}
+
+/**
+ * Formats variables with JSON.
+ */
+function drush_output_format_json($input, $label = NULL) {
+  // JSON can display the label as the key in an associative array.
+  if ($label) {
+    $input = array($label => $input);
   }
-  return $output;
+  return drush_json_encode($input);
 }
 
 /**
