← Back to list

How to Use Google Sheets as a Free Backend for Your Website Contact Form

Easily collect form submissions on your website without paying for a backend. Learn how to use Google Sheets as a free, no-code form…

Utsav Desai · 2025-05-26 04:38 · 2 claps · 2.5 min read paywalled
#google-sheets-script #portfolio #backend #database #no-code
Open on Medium ↗
Wiki topics: INV · Investing & Markets 🌐 · Web Development

How to Use Google Sheets as a Free Backend for Your Website Contact Form

Easily collect form submissions on your website without paying for a backend. Learn how to use Google Sheets as a free, no-code form database in minutes.

Not a Medium member? No worries — get free access click this **Friend Link**.

Starting a new project — whether it’s a personal portfolio, landing page, or an early-stage startup — often comes with one big constraint: budget.

If you’re looking for a free, easy-to-manage, and reliable backend to collect form submissions (like contact messages or leads), this guide is exactly what you need.

With just a Google account, you’ll be able to:

  • Set up a working form backend
  • Collect entries in real-time
  • Avoid paid databases or hosting fees

Let’s turn Google Sheets into your custom backend — without any monthly cost.

What You’ll Need

  • A Google Sheet
  • Access to Google Apps Script
  • A contact form on your website (HTML or any builder like Webflow, Wix, etc.)
  • Internet access 😄

Step 1: Create Your Google Sheet

  1. Open Google Sheets.

  2. Create a new spreadsheet.

  3. In the first row, define your fields:

  • name | email | message | date
  1. Rename your sheet tab to Sheet1 if it's not already.

This sheet will act as your free database.

Step 2: Write the Script to Handle Submissions

  1. From your spreadsheet, click: Extensions → Apps Script

  2. Replace the default code with this:

function doPost(e) {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1");
  const data = JSON.parse(e.postData.contents);

  sheet.appendRow([data.name, data.email, data.message, new Date()]);

  return ContentService
    .createTextOutput(JSON.stringify({ status: "success" }))
    .setMimeType(ContentService.MimeType.JSON);
}
  1. Click the disk icon to save. Name it something like FormHandler.

Step 3: Deploy Your Script as a Web App

  1. Click Deploy → Test deployments → Web App
  2. Under “Who has access,” select: Anyone
  3. Click Deploy and allow required permissions.

You’ll get a unique URL — this is the endpoint where your form will send data!

Example: [https://script.google.com/macros/s/AKfy.../exec](https://script.google.com/macros/s/AKfy.../exec)

Step 4: Connect Your Form to the Script

Here’s a basic structure of how your contact form should send the data:

<form id="contact-form">
  <input type="text" name="name" placeholder="Your Name" required />
  <input type="email" name="email" placeholder="Your Email" required />
  <textarea name="message" placeholder="Your Message" required></textarea>
  <button type="submit">Send</button>
</form>

<script>
  const form = document.getElementById("contact-form");
  form.addEventListener("submit", async (e) => {
    e.preventDefault();

    const data = {
      name: form.name.value,
      email: form.email.value,
      message: form.message.value,
    };

    try {
      await fetch("https://script.google.com/macros/s/AKfy.../exec", {
        method: "POST",
        body: JSON.stringify(data),
        headers: {
          "Content-Type": "application/json",
        },
      });

      alert("Message sent successfully!");
      form.reset();
    } catch (err) {
      alert("Something went wrong. Please try again.");
    }
  });
</script>

This will send your form data directly into your Google Sheet. ✅

Why This Works So Well

  • Zero cost — No backend, no database, no server bills
  • Simple setup — All you need is a Google account
  • Easily review submissions — Everything lands in a spreadsheet
  • No third-party dependency — No form platforms, no APIs

Bonus Tip: Add Basic Spam Protection

To prevent spam bots, consider:

  • Adding Google reCAPTCHA
  • Using a hidden honeypot field
  • Disabling autocomplete on sensitive fields

Conclusion

If you’re building a personal website, launching a side project, or validating a business idea, you don’t need to spend money on a backend. Google Sheets + Apps Script gives you a powerful and completely free way to handle form submissions like a pro.

It’s not just a temporary solution — it’s a smart move for lean teams and solo creators who want to ship fast and smart.

I have used this technique in my personal portfolio. You can check it out below.

Utsav Desai (Full Stack Dev & DevOps Expert)


메타데이터
post_id
dc6e6844a9f9
slug
how-to-use-google-sheets-as-a-free-backend-for-your-website-contact-form-dc6e6844a9f9
url
https://medium.com/@utsavdesai26/how-to-use-google-sheets-as-a-free-backend-for-your-website-contact-form-dc6e6844a9f9
canonical_url
https://medium.com/@utsavdesai26/how-to-use-google-sheets-as-a-free-backend-for-your-website-contact-form-dc6e6844a9f9
author_url
https://medium.com/@utsavdesai26
status
ok
fetched_at
2026-08-03 12:36:00