Skip to content

Instantly share code, notes, and snippets.

Last active November 4, 2021 11:13
What would you like to do?
How to get a Google Sheet as JSON

How to get a Google Sheet as JSON

Preparing Your Google Sheet

  1. The first row of your spreadsheet should be headers, and the rest is data under those headers (see example).
  2. Share the spreadsheet so anyone can see it (“Share” button in top right corner > “Anyone on the internet with this link can view”).

Preparing you url access

fetch('' +
           spreadsheet_id + '/values/' + tab_name +
           '?alt=json&key=' + api_key')
.then(data => {
return data.json();
.then(data => {

spreadsheet_id is the long string of letters and numbers in the address of the spreadsheet — it is the bit between /d/ and /edit

tab_name is the name of the sheet, i.e., the name you see in the tab bar at the bottom of the window when you have the spreadsheet open for editing The secret: don't use a number for this name

api_key is the API key you get from Google Cloud Platform Console

Example finally url:

Best alternative


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment