Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <h1>Google Spreadsheet to JSON Converter</h1>
<p>It's pretty useful to be able to get data from a Google Spreasheet as JSON, however it takes a bit of messing around with the URL to do so. This little converter should help.</p>
<p>The best part is that this tool handles mutiple sheets, returning the right sheet ID for whichever is specified in the URL</p>
<div ng-app="app">
  <div ng-controller="controller">
    <h2>Enter Your Google Spreadsheet URL here</h2>
    <small><a href="" target="_blank">Make sure it's published to the web <span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span>
    <form ng-submit="getGoogleJSON(inputURL)">
      <input type="text" ng-model="inputURL" />
      <input class="btn btn-lg btn-success" type="submit" />
    <span class="error">{{error}}</span>
    <div class="result" ng-show="newURL">
      <h3>Your new URL is:</h3>
      <small><a ng-href="{{newURL}}" target="_blank">Open URL <span class="glyphicon glyphicon-new-window" aria-hidden="true"></span>

      <!-- Nav tabs -->
      <ul class="nav nav-tabs" role="tablist">
        <li role="presentation"><a href="#jquery" class="active" aria-controls="jquery" role="tab" data-toggle="tab">JQuery</a></li>
        <li role="presentation"><a href="#angular" aria-controls="angular" role="tab" data-toggle="tab">AngularJS</a></li>
        <li role="presentation"><a href="#json" aria-controls="json" role="tab" data-toggle="tab">JSON Response</a></li>

      <!-- Tab panes -->
      <div class="tab-content">
        <div role="tabpanel" class="tab-pane" id="jquery">
        $.get('{{newURL}}', function(data){
          var entries = data.feed.entry;
            // Do something with each entry
        <div role="tabpanel" class="tab-pane" id="angular">
          // Assign data to scope
          $ =;
        <div role="tabpanel" class="tab-pane" id="json">
          <pre>{{JSONData | json}}</pre>


                body {

p {
  margin:20px auto;

h1, h2, h3 {
input {
  display:block !important;
  margin:10px auto !important;
    padding: 10px;

.result {
  pre {
    padding:0 10px;

.error {


                (function() {
  var app = angular.module('app', []);

  app.controller('controller', function($scope, $http) {

    // Default URL
    $scope.inputURL = "";

    // Convert the URL function
    $scope.getGoogleJSON = function(url) {

        // Clear newURL
        $scope.newURL = '';

        // Empty array for all the original grid IDs
        $scope.oldGrids = [];
        // Empty array for all the new grid IDs
        $scope.newGrids = [];

        // Get the spreadsheet ID from the URL
        var id;
        var preString = url.substring(url.indexOf('/d/') + 3);
        if (preString.indexOf('/') > -1) {
          id = preString.substring(0, preString.indexOf('/'));
        } else {
          id = preString;

        // Get the grid ID from the URL
        var grid = url.substring(url.indexOf('=') + 1);

        // Get XML data of the spreadhseet which includes the new IDs. Using to avoid cross origin errors. This is for when a spreadsheet has multiple sheets
        $http.get('' + id + '/public/full').then(function(response) {

            // Parse the response as xml
            var xml = $($.parseXML(;
            // Find each entry and loop through
            $(xml).find('entry').each(function() {
                // Get each old grid ID from XML data - contained in a '<link>'
                var oldGridSrc = $(this).children('link[rel=""]').attr('href');
                // Chop the ID from the end of the href
                var oldGrid = oldGridSrc.substring(oldGridSrc.indexOf('=') + 1, oldGridSrc.indexOf('&'))

                // Find the '<id>' element in the xml. This contains the new Grid ID
                var newGridSrc = $(this).children('id').text();
                // Chop the ID from the end of the string
                var newGrid = newGridSrc.substring(newGridSrc.lastIndexOf('/') + 1);

                // Push new Grid ID to array
                // Push old Grid ID to array

              }) // End Each

            // Get new Grid ID by cross referencing the original grid ID in the oldGrids array, return the index, and use that index to get the new Grid ID from the newGrids array. If undefined set to '1' which is the default for the first sheet
            $scope.newGridID = $scope.newGrids[$scope.oldGrids.indexOf(grid)] || '1';

            // Compose new URL
            $scope.newURL = '' + id + '/' + $scope.newGridID + '/public/values?alt=json';

            // Get JSON Response
            $http.get($scope.newURL).then(function(response) {
              $scope.JSONData =;

            // Show first tab
            $('.nav-tabs a:first').tab('show');

            setTimeout(function() {
              $('pre code').each(function(i, block) {
            }, 500);
          }, function(response){
            $scope.error = "Sorry, there has been an error. Please check your Spreadsheet URL";
        }) // End $http.get

      } // End getGoogleJSON function

  }); // End Controller