To convert Google Sheets to JSON, you have several methods depending on your needs—manual, formula-based, script-based, or via API. Here’s how you can do each:
Method 1: Publish to Web (Simple Public JSON)
-
Open Google Sheets.
-
Click File > Share > Publish to web.
-
Select the sheet and publish it.
-
Copy the Sheet ID from the URL (
https://docs.google.com/spreadsheets/d/
SHEET_ID/edit
). -
Use the following URL format to get JSON (using a public API by Google Visualization):
✅ Easy but only works for public sheets and returns a nested JSON format that needs to be cleaned.
Method 2: Use Google Apps Script (Custom JSON Format)
-
Go to your Google Sheet.
-
Click Extensions > Apps Script.
-
Paste the following script:
-
Click Deploy > Test deployments or Deploy > New deployment, and enable web access.
-
You’ll get a URL that returns your sheet data as JSON.
✅ Great for private sheets and custom formatting.
🔐 You can set permissions.
Method 3: Export as CSV, Then Convert to JSON
-
File > Download > Comma-separated values (.csv).
-
Convert CSV to JSON using an online tool or a script.
Example using JavaScript:
Method 4: Use Third-party Tools or Add-ons
-
Tools: SheetDB, Blockspring, or Zapier.
-
Add-ons: Search for “JSON Export” add-ons in Google Sheets.
Best Practice Tips
-
Use headers in the first row to define keys in your JSON.
-
Clean your data (no merged cells, hidden rows).
-
For API-like use, the Apps Script method is most reliable.
Let me know if you want the JSON formatted in a specific way (nested, flat, etc.).
Leave a Reply