diff --git a/tablefield.module b/tablefield.module
index 88a74b6..e17217f 100644
--- a/tablefield.module
+++ b/tablefield.module
@@ -1,4 +1,5 @@
 <?php
+
 /**
  * @file
  * Provides a set of fields that can be used to store tabular data with a node.
@@ -344,7 +345,34 @@ function tablefield_field_is_empty($item, $field) {
 function tablefield_field_formatter_info() {
   return array(
     'tablefield_default' => array(
-      'label' => t('Tabular View'),
+      'label' => t('Tabular view'),
+      'field types' => array('tablefield'),
+      'settings' => array(
+        'trim_trailing_rows' => FALSE,
+        'trim_trailing_cols' => FALSE,
+        'hide_cols_skip_head' => FALSE,
+      ),
+    ),
+    'format_raw' => array(
+      'label' => t('Raw data (JSON)'),
+      'field types' => array('tablefield'),
+      'settings' => array(
+        'trim_trailing_rows' => FALSE,
+        'trim_trailing_cols' => FALSE,
+        'hide_cols_skip_head' => FALSE,
+      ),
+    ),
+    'format_raw_header_keys' => array(
+      'label' => t('Raw data (JSON) with header values as keys (if not empty)'),
+      'field types' => array('tablefield'),
+      'settings' => array(
+        'trim_trailing_rows' => FALSE,
+        'trim_trailing_cols' => FALSE,
+        'hide_cols_skip_head' => FALSE,
+      ),
+    ),
+    'format_raw_custom_keys' => array(
+      'label' => t('Raw data (JSON) with field label, header and first column values as keys (if not empty)'),
       'field types' => array('tablefield'),
       'settings' => array(
         'trim_trailing_rows' => FALSE,
@@ -407,100 +435,241 @@ function tablefield_field_formatter_view($entity_type, $entity, $field, $instanc
   $element = array();
   $settings = $display['settings'];
   $formatter = $display['type'];
+  $prettyprint = FALSE;
+  if (!empty($items)) {
+    $i = 0;
+    $len = count($items);
+    foreach ($items as $delta => $table) {
+      // If we are not on the last iteration of the loop use a separator.
+      $separator = ($i == $len - 1) ? '' : ',';
+      switch ($display['type']) {
+        case 'format_raw':
+          $value = unserialize($table['value']);
+          // Remove unneeded data.
+          unset($value['rebuild']);
+          unset($value['import']);
+          unset($value['paste']);
+          foreach ($value['tabledata'] as $key => $row) {
+            unset($row['weight']);
+            $value['tabledata'][$key] = $row;
+          }
+          // Assign the markup showing pretty print on node pages.
+          if (menu_get_object()) {
+            $prettyprint = TRUE;
+            $element[$delta] = array(
+              '#markup' => str_replace(array("\r", "\n", "\t"), "<br />", json_encode($value, JSON_PRETTY_PRINT)) . $separator,
+            );
+          }
+          // And raw on other pages.
+          else {
+            $element[$delta] = array(
+              '#markup' => drupal_json_encode($value),
+            );
+          }
+          break;
+
+        case 'format_raw_header_keys':
+          $value = unserialize($table['value']);
+          // Remove unneeded data.
+          unset($value['rebuild']);
+          unset($value['import']);
+          unset($value['paste']);
+          // Keep first row values (header) to use for array keys later.
+          $keys = $value['tabledata']['row_0'];
+          // If a header value is empty use the column key (col_#).
+          foreach ($keys as $key => $content) {
+            if (empty($content)) {
+              $keys[$key] = $key;
+            }
+          }
+          // Inform the user about columns with duplicate names being suppressed.
+          $unique = array_unique($keys);
+          $duplicates = array_diff_assoc($keys, $unique);
+          foreach ($duplicates as $duplicate) {
+            drupal_set_message(t('The column header "%key" appears multiple times in a table. In the JSON output only the last column with this key is used to avoid duplicate names.', array('%key' => $duplicate)), 'warning', FALSE);
+          }
+          unset($keys['weight']);
+          // Remove the first row (header).
+          unset($value['tabledata']['row_0']);
+          foreach ($value['tabledata'] as $key => $row) {
+            unset($row['weight']);
+            $row = array_combine($keys, $row);
+            $value['tabledata'][$key] = $row;
+          }
+          // Assign the markup showing pretty print on node pages.
+          if (menu_get_object()) {
+            $prettyprint = TRUE;
+            $element[$delta] = array(
+              '#markup' => str_replace(array("\r", "\n", "\t"), "<br />", json_encode($value, JSON_PRETTY_PRINT)) . $separator,
+            );
+          }
+          // And raw on other pages.
+          else {
+            $element[$delta] = array(
+              '#markup' => drupal_json_encode($value) . $separator,
+            );
+          }
+          break;
+
+        case 'format_raw_custom_keys':
+          $value = unserialize($table['value']);
+          // Remove unneeded data.
+          unset($value['rebuild']);
+          unset($value['import']);
+          unset($value['paste']);
+          // Keep first row values (header) to use for array keys later.
+          $keys = $value['tabledata']['row_0'];
+          // If a header value is empty use the column key (col_#).
+          foreach ($keys as $key => $content) {
+            if (empty($content)) {
+              $keys[$key] = $key;
+            }
+          }
+          // Inform the user about columns with duplicate names being suppressed.
+          $unique = array_unique($keys);
+          $duplicates = array_diff_assoc($keys, $unique);
+          foreach ($duplicates as $duplicate) {
+            drupal_set_message(t('The column header "%key" appears multiple times in a table. In the JSON output only the last column with this key is used to avoid duplicate names.', array('%key' => $duplicate)), 'warning', FALSE);
+          }
+          // Remove the first row (header).
+          unset($value['tabledata']['row_0']);
+          // Remove the first column from the keys.
+          unset($keys['col_0']);
+          // Make number of elements same as $row (needed for array_combine).
+          unset($keys['weight']);
+          foreach ($value['tabledata'] as $key => $row) {
+            $row_id = $row['col_0'];
+            // Clean up unneeded data.
+            unset($value['tabledata'][$key]);
+            unset($row['col_0']);
+            unset($row['weight']);
+            $row = array_combine($keys, $row);
+            // If the first column value is empty use the row key (row_#).
+            $row_id = empty($row_id) ? $key : $row_id;
+            // Inform the user about rows with duplicate names being suppressed.
+            if (isset($value['tabledata'][$row_id])) {
+              drupal_set_message(t('The row header "%row_id" appears multiple times in a table. In the JSON output only the last row with this key is used to avoid duplicate names.', array('%row_id' => $row_id)), 'warning', FALSE);
+            }
+            $value['tabledata'][$row_id] = $row;
+          }
+          // Swap the original key with the field label to have complete control.
+          $value[$instance['label']] = $value['tabledata'];
+          unset($value['tabledata']);
+          // Assign the markup showing pretty print on node pages.
+          if (menu_get_object()) {
+            $prettyprint = TRUE;
+            $element[$delta] = array(
+              '#markup' => str_replace(array("\r", "\n", "\t"), "<br />", json_encode($value, JSON_PRETTY_PRINT)) . $separator,
+            );
+          }
+          // And raw on other pages.
+          else {
+            $element[$delta] = array(
+              '#markup' => drupal_json_encode($value) . $separator,
+            );
+          }
+          break;
 
-  foreach ($items as $delta => $table) {
-    // Check for table caption.
-    $raw = unserialize($table['value']);
-    $caption = isset($raw['caption']) ? check_plain($raw['caption']) : '';
-
-    // Rationalize the stored data.
-    if (!empty($table['tablefield'])) {
-      $tabledata = $table['tablefield'];
-    }
-    elseif (!empty($table['value'])) {
-      $tabledata = unserialize($table['value']);
-    }
-
-    // Run the table through input filters.
-    if (isset($tabledata['tabledata'])) {
-      if (!empty($tabledata['tabledata'])) {
-
-        if (!empty($settings['trim_trailing_rows'])) {
-          $tabledata['tabledata'] = tablefield_rtrim_rows($tabledata['tabledata']);
-        }
-
-        if (!empty($settings['trim_trailing_cols'])) {
-          $tabledata['tabledata'] = tablefield_rtrim_cols($tabledata['tabledata']);
-        }
+        default:
+          // Check for table caption.
+          $raw = unserialize($table['value']);
+          $caption = isset($raw['caption']) ? check_plain($raw['caption']) : '';
 
-        if (!empty($settings['hide_cols_skip_head'])) {
-          $tabledata['tabledata'] = tablefield_rtrim_cols($tabledata['tabledata'], TRUE);
-        }
+          // Rationalize the stored data.
+          if (!empty($table['tablefield'])) {
+            $tabledata = $table['tablefield'];
+          }
+          elseif (!empty($table['value'])) {
+            $tabledata = unserialize($table['value']);
+          }
 
-        foreach ($tabledata['tabledata'] as $row_key => $row) {
-          foreach ($row as $col_key => $cell) {
-            if (!empty($table['format']) && $col_key !== 'weight') {
-              $tabledata[$row_key][$col_key] = array(
-                'data' => check_markup($cell, $table['format']),
-                'class' => array($row_key, $col_key),
-              );
+          // Run the table through input filters.
+          if (isset($tabledata['tabledata'])) {
+            if (!empty($tabledata['tabledata'])) {
+
+              if (!empty($settings['trim_trailing_rows'])) {
+                $tabledata['tabledata'] = tablefield_rtrim_rows($tabledata['tabledata']);
+              }
+
+              if (!empty($settings['trim_trailing_cols'])) {
+                $tabledata['tabledata'] = tablefield_rtrim_cols($tabledata['tabledata']);
+              }
+
+              if (!empty($settings['hide_cols_skip_head'])) {
+                $tabledata['tabledata'] = tablefield_rtrim_cols($tabledata['tabledata'], TRUE);
+              }
+
+              foreach ($tabledata['tabledata'] as $row_key => $row) {
+                foreach ($row as $col_key => $cell) {
+                  if (!empty($table['format']) && $col_key !== 'weight') {
+                    $tabledata[$row_key][$col_key] = array(
+                      'data' => check_markup($cell, $table['format']),
+                      'class' => array($row_key, $col_key),
+                    );
+                  }
+                  elseif ($col_key !== 'weight') {
+                    $tabledata[$row_key][$col_key] = array(
+                      'data' => check_plain($cell),
+                      'class' => array($row_key, $col_key),
+                    );
+                  }
+                }
+              }
             }
-            elseif ($col_key !== 'weight') {
-              $tabledata[$row_key][$col_key] = array(
-                'data' => check_plain($cell),
-                'class' => array($row_key, $col_key),
-              );
+
+            // Pull the header for theming.
+            unset($tabledata['caption']);
+            unset($tabledata['tabledata']);
+            unset($tabledata['rebuild']);
+            unset($tabledata['import']);
+            unset($tabledata['paste']);
+            $header_data = isset($tabledata['row_0']) ? $tabledata['row_0'] : NULL;
+
+            // Check for an empty header, if so we don't want to theme it.
+            $noheader = TRUE;
+            if (empty($field['settings']['hide_headers']) && $header_data) {
+              foreach ($header_data as $cell) {
+                if (strlen($cell['data']) > 0) {
+                  $noheader = FALSE;
+                  break;
+                }
+              }
             }
-          }
-        }
-      }
 
-      // Pull the header for theming.
-      unset($tabledata['caption']);
-      unset($tabledata['tabledata']);
-      unset($tabledata['rebuild']);
-      unset($tabledata['import']);
-      unset($tabledata['paste']);
-      $header_data = isset($tabledata['row_0']) ? $tabledata['row_0'] : NULL;
-
-      // Check for an empty header, if so we don't want to theme it.
-      $noheader = TRUE;
-      if (empty($field['settings']['hide_headers']) && $header_data) {
-        foreach ($header_data as $cell) {
-          if (strlen($cell['data']) > 0) {
-            $noheader = FALSE;
-            break;
+            $header = $noheader ? NULL : $header_data;
+            $entity_info = entity_get_info($entity_type);
+            $entity_id = !empty($entity_info['entity keys']['id']) ? $entity->{$entity_info['entity keys']['id']} : NULL;
+
+            // Remove the first row from the tabledata.
+            array_shift($tabledata);
+            // Theme the table for display.
+            $element[$delta] = array(
+              '#theme' => 'tablefield_view',
+              '#attributes' => array(
+                'id' => drupal_html_id('tablefield-' . $delta),
+                'class' => array('tablefield'),
+              ),
+              '#caption' => $caption,
+              '#sticky' => isset($field['settings']['sticky']) ? $field['settings']['sticky'] : NULL,
+              '#header' => $header,
+              '#rows' => $tabledata,
+              '#delta' => $delta,
+              '#export' => isset($field['settings']['export']) ? $field['settings']['export'] : NULL,
+              '#entity_type' => $entity_type,
+              '#entity_id' => $entity_id,
+              '#field_name' => $field['field_name'],
+              '#langcode' => $langcode,
+              '#formatter' => $formatter,
+            );
           }
-        }
+          break;
       }
-
-      $header = $noheader ? NULL : $header_data;
-      $entity_info = entity_get_info($entity_type);
-      $entity_id = !empty($entity_info['entity keys']['id']) ? $entity->{$entity_info['entity keys']['id']} : NULL;
-
-      // Remove the first row from the tabledata.
-      array_shift($tabledata);
-      // Theme the table for display.
-      $element[$delta] = array(
-        '#theme' => 'tablefield_view',
-        '#attributes' => array(
-          'id' => drupal_html_id('tablefield-' . $delta),
-          'class' => array('tablefield'),
-        ),
-        '#caption' => $caption,
-        '#sticky' => isset($field['settings']['sticky']) ? $field['settings']['sticky'] : NULL,
-        '#header' => $header,
-        '#rows' => $tabledata,
-        '#delta' => $delta,
-        '#export' => isset($field['settings']['export']) ? $field['settings']['export'] : NULL,
-        '#entity_type' => $entity_type,
-        '#entity_id' => $entity_id,
-        '#field_name' => $field['field_name'],
-        '#langcode' => $langcode,
-        '#formatter' => $formatter,
-      );
+      $i++;
     }
-
+  }
+  if ($prettyprint) {
+    $element['#prefix'] = '<pre>';
+    $element['#suffix'] = '</pre>';
   }
   return $element;
 }
