Google Sheets is a powerful cloud-based spreadsheet tool used for managing and organizing data. Sometimes, especially in web development or app integration, you may need to convert Google Sheet data into JSON (JavaScript Object Notation). JSON is a lightweight data-interchange format that is easy for machines to parse and generate, and easy for humans to read and write.
This guide will walk you through multiple ways to save or export Google Sheets as JSON, using both built-in tools and custom Google Apps Script. No plugins required, and you can automate the process as needed.
There are several reasons why converting Google Sheets to JSON is useful:
Frontend Web Development: Load live data from Google Sheets into your JavaScript web app.
API Emulation: Turn a Sheet into a makeshift API.
Mobile App Development: Use it as a lightweight backend.
Data Portability: JSON is a widely accepted data format.
Google Sheets allows you to publish a spreadsheet to the web. You can then fetch the data using a simple GET request and convert it to JSON.
Go to your Google Sheet.
Make sure your data is in a clean tabular format. The first row should contain column headers.
Give your spreadsheet and sheet tab meaningful names.
Click on File > Share > Publish to Web.
Choose:
Entire Document or Specific Sheet
Format: Web page
Click Publish.
You will get a public URL like:
https://docs.google.com/spreadsheets/d/e/2PACX-1vQxyz123abc/pubhtml
Unfortunately, this gives an HTML version, not JSON.
The Google Sheets API v4 allows you to programmatically fetch data and convert it into JSON.
Go to Google Cloud Console.
Create a new project.
Enable the Google Sheets API.
Create credentials (OAuth 2.0 or API key).
Share your sheet with the service account email, if using OAuth.
Make a GET request:
GET https://sheets.googleapis.com/v4/spreadsheets/SPREADSHEET_ID/values/SHEET_NAME?key=API_KEY
The response will be in JSON like:
{
"range": "Sheet1!A1:C3",
"majorDimension": "ROWS",
"values": [
["Name", "Age", "City"],
["Ravi", "25", "Mumbai"],
["Neha", "30", "Delhi"]
]
}
Google Apps Script provides the simplest and most flexible method for converting a Google Sheet to JSON—especially if you don’t want to deal with APIs or developer credentials.
In your Google Sheet, click on Extensions > Apps Script.
function doGet() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1");
var data = sheet.getDataRange().getValues();
var headers = data[0];
var json = [];
for (var i = 1; i < data.length; i++) {
var row = {};
for (var j = 0; j < headers.length; j++) {
row[headers[j]] = data[i][j];
}
json.push(row);
}
return ContentService
.createTextOutput(JSON.stringify(json))
.setMimeType(ContentService.MimeType.JSON);
}
Click Deploy > Manage deployments.
Click New deployment.
Select Web App.
Set access to Anyone.
Click Deploy.
You’ll receive a public URL like:
https://script.google.com/macros/s/AKfycbxyz123/exec
Visiting this link will return your Google Sheet’s data as JSON.
[
{
"Name": "Ravi",
"Age": 25,
"City": "Mumbai"
},
{
"Name": "Neha",
"Age": 30,
"City": "Delhi"
}
]
If you only need one-time export:
Go to File > Download > Comma-separated values (.csv).
Use any online tool or script to convert CSV to JSON.
In a Google Colab notebook:
import pandas as pd
sheet_url = "https://docs.google.com/spreadsheets/d/<SHEET_ID>/export?format=csv"
df = pd.read_csv(sheet_url)
json_data = df.to_json(orient='records')
print(json_data)
This pulls data directly and converts it to JSON.
Always keep the first row of your Sheet reserved for column headers.
Avoid blank rows and columns.
If using public access or Web Apps, don’t include sensitive data.
For dynamic data that updates frequently, prefer Apps Script-based JSON endpoints or Google Sheets API.
Add caching mechanisms for performance if you are hitting the API frequently.
Converting Google Sheets to JSON opens up a wide array of possibilities—from building real-time dashboards to mobile app integrations. Depending on your level of technical expertise and use case, you can choose from:
Simple Web Publishing + Script
Full-fledged API access
Custom Web App using Apps Script
Manual CSV + JSON conversion
Each method has its pros and cons. For most users, Google Apps Script is the fastest, easiest, and most powerful method for getting live JSON from Sheets.
Let Google Sheets become your mini-database, and use the power of JSON to bring your apps to life.