DEV Community

Cover image for How to Use Google Sheets as a Free Database with n8n
Raizan
Raizan

Posted on • Originally published at chasebot.online

How to Use Google Sheets as a Free Database with n8n

What You'll Need

  • n8n Cloud or self-hosted n8n
  • Hetzner VPS or Contabo VPS for self-hosting
  • A Google account with Google Sheets access
  • Basic familiarity with n8n (optional—I'll walk you through it)

Table of Contents


Why Google Sheets as a Database?

I started using Google Sheets as a database when I was bootstrapping projects and couldn't justify $50/month for a traditional database. Honestly? It works incredibly well for small to medium workflows.

Here's why I love it:

Free and unlimited rows. Google Sheets gives you enough space for thousands of records without paying a cent.

Built-in collaboration. Multiple team members can view and comment on data in real-time.

Easy backups. Google handles versioning automatically.

Zero setup. No Docker containers, no PostgreSQL configuration, no DevOps headaches.

Native n8n integration. The Google Sheets node in n8n is rock-solid and handles authentication seamlessly.

The downside? It's slower than a true database at scale (10,000+ rows), but for workflows under 5,000 records, you won't notice a difference. I've actually built workflows that replace $200/month in SaaS tools using nothing but Google Sheets and n8n.


Setting Up Google Sheets Credentials in n8n

Before you write a single workflow, you need to authenticate Google Sheets in n8n Cloud.

Step 1: Create a new workflow in n8n

Log into your n8n account and click "New Workflow."

Step 2: Add a Google Sheets node

Search for "Google Sheets" in the node panel and drag it onto your canvas.

Step 3: Authenticate with Google

Click the "Authenticate" button (the credential field). A popup will appear asking for permission. Sign in with your Google account and authorize n8n to access your Google Sheets.

Here's what the credential connection looks like in the node configuration:

{
  "authentication": "oAuth2",
  "client_id": "YOUR_GOOGLE_CLIENT_ID",
  "client_secret": "YOUR_GOOGLE_CLIENT_SECRET",
  "redirect_uri": "https://n8n.yourinstance.com/oauth-callback"
}
Enter fullscreen mode Exit fullscreen mode

If you're self-hosting n8n on a Hetzner VPS or DigitalOcean, you'll need to set up OAuth credentials in the Google Cloud Console:

  1. Go to console.cloud.google.com
  2. Create a new project called "n8n Workflows"
  3. Enable the Google Sheets API and Google Drive API
  4. Create an OAuth 2.0 credential (Application type: Web application)
  5. Set authorized redirect URI to https://your-n8n-domain.com/oauth-callback
  6. Copy the Client ID and Secret into n8n

That's it. You're ready to read and write data.


Building Your First Read Workflow

Let me show you how to read data from a Google Sheet. I'm assuming you have a spreadsheet already created—if not, create one and add some test data.

The setup:

  • Sheet name: Contacts
  • Columns: Name, Email, Phone, Status

Here's a simple workflow that reads all rows:

Step 1: Add a Google Sheets node set to "Read"

In the node configuration:

Operation: Read
Spreadsheet: Select your spreadsheet from the dropdown
Sheet: Contacts
Read from: A1 (top-left corner)
First Row as Headers: Yes
Enter fullscreen mode Exit fullscreen mode

Step 2: Add a function node to transform the data

This optional node cleans up the response and makes it easier to work with:

return $input.all().map(item => {
  return {
    name: item.json.Name,
    email: item.json.Email,
    phone: item.json.Phone,
    status: item.json.Status
  };
});
Enter fullscreen mode Exit fullscreen mode

Step 3: Test and execute

Click "Execute" and you'll see the data returned as a JSON array. Each row from your sheet becomes an object:

[
  {
    "name": "Alice Johnson",
    "email": "alice@example.com",
    "phone": "555-0101",
    "status": "Active"
  },
  {
    "name": "Bob Smith",
    "email": "bob@example.com",
    "phone": "555-0102",
    "status": "Inactive"
  }
]
Enter fullscreen mode Exit fullscreen mode

That's it. You're now reading from Google Sheets inside n8n.

💡 Fast-Track Your Project: Don't want to configure this yourself? I build custom n8n pipelines and bots. Message me with code SYS3-DEVTO.


Writing Data to Sheets

Reading is half the battle. Here's how to write new records back to your spreadsheet.

Scenario: You're capturing form submissions via webhook and need to log them to Google Sheets.

Step 1: Add a Webhook trigger

Method: POST
Path: /form-submission
Authentication: None (for testing; add auth in production)
Enter fullscreen mode Exit fullscreen mode

Step 2: Add a Google Sheets node set to "Append"

Configure it like this:

Operation: Append
Spreadsheet: Your spreadsheet
Sheet: Contacts
Columns to Insert: Name, Email, Phone, Status
Enter fullscreen mode Exit fullscreen mode

Step 3: Map the incoming webhook data to sheet columns

In the "Values" section, reference the webhook body:

Name: {{ $json.body.name }}
Email: {{ $json.body.email }}
Phone: {{ $json.body.phone }}
Status: "New"
Enter fullscreen mode Exit fullscreen mode

Step 4: Test with a POST request

Use curl or Postman:

curl -X POST https://your-n8n-instance.com/webhook/form-submission \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Charlie Brown",
    "email": "charlie@example.com",
    "phone": "555-0103"
  }'
Enter fullscreen mode Exit fullscreen mode

Check your Google Sheet—the new row will appear instantly.

Want to update an existing row instead of appending?

Use the "Update" operation:

Operation: Update
Spreadsheet: Your spreadsheet
Sheet: Contacts
Key: Email (the column that identifies the row)
Values: Update Name, Status, Phone as needed
Enter fullscreen mode Exit fullscreen mode

Advanced: Multi-Sheet Workflows and Error Handling

Once you master basic read/write, you can build more sophisticated workflows. Here's a real-world example: syncing leads from a webhook to multiple sheets based on their source.

Step 1: Webhook trigger

Accepts incoming lead data:

{
  "name": "Diana Prince",
  "email": "diana@example.com",
  "source": "facebook",
  "budget": "5000"
}
Enter fullscreen mode Exit fullscreen mode

Step 2: Route based on source

Add an "If" node to branch the workflow:

Condition: source == "facebook"
Enter fullscreen mode Exit fullscreen mode

Step 3: Append to the appropriate sheet

If source is "facebook," append to a "Facebook Leads" sheet:

Operation: Append
Spreadsheet: Your spreadsheet
Sheet: Facebook Leads
Columns: Name, Email, Budget, DateReceived
Values:
  Name: {{ $json.body.name }}
  Email: {{ $json.body.body.email }}
  Budget: {{ $json.body.budget }}
  DateReceived: {{ new Date().toISOString() }}
Enter fullscreen mode Exit fullscreen mode

Otherwise, append to a "Other Leads" sheet.

Step 4: Add error handling

Wrap the Google Sheets operations in a "Try-Catch" node to gracefully handle failures:

Try: Google Sheets - Append node
Catch: Send notification if append fails
Enter fullscreen mode Exit fullscreen mode

The catch block might look like this:

return {
  error: true,
  message: "Failed to append lead to Google Sheets",
  details: $json.error.message,
  lead: $json.body
};
Enter fullscreen mode Exit fullscreen mode

You could then send this to a Slack channel or email for manual review. If you want to monitor failures across all your workflows, I'd recommend setting up VPS health check workflows that alert you to any repeated errors.


Advanced Tip: Filtering and Conditional Writes

Here's a workflow pattern I use constantly: only write data to Google Sheets if it meets certain criteria.

Step 1: Add a filter node after webhook trigger

Condition: email contains "@company.com" AND budget > 1000
Enter fullscreen mode Exit fullscreen mode

This ensures only qualified leads get recorded.

Step 2: Append only if condition is true

The Google Sheets node only runs if the filter passes. Non-matching records can go to a separate sheet or be logged elsewhere.


Common Issues and Solutions

Issue: "Spreadsheet not found"

Make sure the Google account you authenticated with actually has access to the spreadsheet. Also verify the spreadsheet hasn't been moved to a shared drive (those require different permissions).

Issue: "Sheet name invalid"

Google Sheets node is case-sensitive. If your sheet is called "Contacts" but you're searching for "contacts," it will fail. Copy-paste the exact sheet name.

Issue: Rate limiting (too many reads/writes per minute)

Google Sheets has soft rate limits (~100 requests per minute per user). If you're doing bulk operations, add a 1-second delay between rows:

Add "Set" node between Google Sheets reads
Delay: {{ setTimeout(() => {}, 1000) }}
Enter fullscreen mode Exit fullscreen mode

Issue: Need to read only specific columns?

Use the "Read Range" operation instead of "Read":

Range: A1:D100
Enter fullscreen mode Exit fullscreen mode

This only reads columns A through D, rows 1 to 100.


Getting Started

You're ready to build. Here's your launch checklist:

  1. Sign up for n8n Cloud (free tier includes 1,000 executions/month)
  2. Create your first Google Sheet and populate it with test data
  3. Add a Google Sheets node and authenticate
  4. Build a simple read workflow to verify everything works
  5. Add a webhook trigger and set up an append operation
  6. Test with sample data before connecting to production

Need hosting? Hetzner VPS or Contabo VPS offer affordable servers if you want to self-host n8n instead of using the cloud version.


Outsource Your Automation

Don't have time? I build production n8n workflows, WhatsApp bots, and fully automated YouTube Shorts pipelines. Hire me on Fiverr — mention SYS3-DEVTO for priority. Or DM at chasebot.online.


Originally published on Automation Insider.

Top comments (0)