Build a To-Do List That Saves Data in Google Sheets Using HTML, CSS, and JavaScript
Introduction
Creating a simple To-Do list is often a beginner-friendly way to practice HTML, CSS, and JavaScript. But what if we take it a step further and store the tasks online in a way that persists even after refreshing the page or switching devices? Enter Google Sheets – a free, cloud-based spreadsheet tool that can act like a database with the help of Google Apps Script.
In this tutorial, we'll build a To-Do list web app from scratch using HTML, CSS, and JavaScript, and then connect it to Google Sheets so that every task is saved, loaded, and managed from a spreadsheet.
Let’s dive in!
Why Google Sheets as a Database?
Using Google Sheets as a backend has several benefits:
It’s free and easy to use.
No need for external hosting or server setup.
Simple to read, write, and modify data.
Can be connected with Google Apps Script to expose REST APIs.
Perfect for small apps, personal projects, and quick prototyping!
Overview of What We'll Build
Our web app will allow users to:
Add tasks to the list
View all saved tasks
Delete individual tasks
Save and load all data from Google Sheets in real-time
We’ll create:
A Google Apps Script to manage sheet data
A frontend UI with HTML and CSS
Functionality using JavaScript to talk to Google Sheets
Step 1: Set Up Your Google Sheet
Go to Google Sheets
Create a new spreadsheet
Name it something like ToDoList
In Row 1, add the column headers: Task
, Timestamp
Go to Google Sheets
Create a new spreadsheet
Name it something like ToDoList
In Row 1, add the column headers: Task
, Timestamp
Keep this sheet open — we’ll connect to it shortly.
Step 2: Create a Google Apps Script API
We’ll now write a Google Apps Script that interacts with your spreadsheet.
1. Open the script editor:
Click Extensions
> Apps Script
Click Extensions
> Apps Script
2. Replace default code with:
This script:
GET
: reads tasks from the sheetPOST
: adds a new task to the sheet
3. Deploy the script as a web app:
Click Deploy > Manage Deployments > New Deployment
Choose "Web app"
Set access to: Anyone
Click Deploy and copy the web app URL
Click Deploy > Manage Deployments > New Deployment
Choose "Web app"
Set access to: Anyone
Click Deploy and copy the web app URL
This URL is your API endpoint.
Step 3: Create Your HTML, CSS, and JavaScript
Let’s now build the frontend.
✅ HTML + CSS + JavaScript (All in One)
Replace "YOUR_GOOGLE_SCRIPT_URL_HERE"
with your deployed Apps Script URL.
How It Works
User enters a task → Clicks "Add"
JS sends a POST
request to Google Script → It saves in the Sheet
Tasks are fetched via GET
and rendered on screen
User enters a task → Clicks "Add"
JS sends a POST
request to Google Script → It saves in the Sheet
Tasks are fetched via GET
and rendered on screen
Handling CORS and Security
For public use, ensure the script is shared as:
Execute as: Me
Accessible to: Anyone
Important: Don’t store sensitive data this way. For authenticated apps, you can use Google OAuth.
Advanced Improvements
1. Delete Tasks
Add an ID or use row index; use Google Sheets API or Apps Script deleteRow()
.
2. Mark as Completed
Add a checkbox and another column Done
.
3. Add Google Login
Use Firebase Auth to restrict users and filter data.
Use Cases Beyond To-Do
Google Sheets is versatile. You can use this same technique for:
Contact forms
Guest books
Survey responses
Inventory lists
Booking systems
Conclusion
Using Google Sheets and Apps Script gives you a powerful backend for lightweight web applications without needing a full database or server.
You’ve now learned:
How to build a frontend with HTML, CSS, JS
How to use Apps Script as a REST API
How to send and fetch data from Google Sheets