Form To Google Sheets

Store HTML form submissions in Google Sheets.
Alternatives To Form To Google Sheets
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Form To Google Sheets3,719
2 months ago53apache-2.0JavaScript
Store HTML form submissions in Google Sheets.
7 hours ago215otherJava
ODK Collect is an Android app for filling out forms. It's been used to collect billions of data points in challenging environments around the world. Contribute and make the world a better place! ✨📋✨
Smart App Rate636
2 years ago11February 13, 20225apache-2.0Kotlin
An Android library that encourages users to rate the app on the Google Play.
Angular Recaptcha5016372 years ago19July 30, 201878mitJavaScript
AngularJS directive to add a reCaptcha widget to your form
Google Custom Form197
6 years ago18HTML
Submit to a google spreadsheet using a form of your own design
6 years ago5
how to put forms which send emails onto static sites
Laravel Google Captcha1802147 months ago21September 14, 20207mitPHP
Google captcha for Laravel 5, Laravel 6, Laravel 7, Laravel 8, Laravel 9 and Laravel 10, support multiple captcha on page
Ngx Captcha14622299 months ago67December 19, 20228mitTypeScript
ReCaptcha components for Angular. Live preview:
Web Form To Google Sheet125
2 years ago18gpl-2.0HTML
A simple example of sending data from an ordinary web form straight to a Google Spreadsheet without a server.
Google Form Clone120
9 months ago10mitHTML
Clone of Google forms built using Django and Javascript
Alternatives To Form To Google Sheets
Select To Compare

Alternative Project Comparisons

Submit a Form to Google Sheets | Demo

How to create an HTML form that stores the submitted form data in Google Sheets using plain 'ol JavaScript (ES6), Google Apps Script, Fetch and FormData.

1. Create a new Google Sheet

  • First, go to Google Sheets and Start a new spreadsheet with the Blank template.
  • Rename it Email Subscribers. Or whatever, it doesn't matter.
  • Put the following headers into the first row:
A B C ...
1 timestamp email

To learn how to add additional input fields, checkout section 7 below.

2. Create a Google Apps Script

  • Click on Tools > Script Editor… which should open a new tab.
  • Rename it Submit Form to Google Sheets. Make sure to wait for it to actually save and update the title before editing the script.
  • Now, delete the function myFunction() {} block within the tab.
  • Paste the following script in it's place and File > Save:
var sheetName = 'Sheet1'
var scriptProp = PropertiesService.getScriptProperties()

function intialSetup () {
  var activeSpreadsheet = SpreadsheetApp.getActiveSpreadsheet()
  scriptProp.setProperty('key', activeSpreadsheet.getId())

function doPost (e) {
  var lock = LockService.getScriptLock()

  try {
    var doc = SpreadsheetApp.openById(scriptProp.getProperty('key'))
    var sheet = doc.getSheetByName(sheetName)

    var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0]
    var nextRow = sheet.getLastRow() + 1

    var newRow = {
      return header === 'timestamp' ? new Date() : e.parameter[header]

    sheet.getRange(nextRow, 1, 1, newRow.length).setValues([newRow])

    return ContentService
      .createTextOutput(JSON.stringify({ 'result': 'success', 'row': nextRow }))

  catch (e) {
    return ContentService
      .createTextOutput(JSON.stringify({ 'result': 'error', 'error': e }))

  finally {

If you want to better understand what this script is doing, checkout the form-script-commented.js file in the repo for a detailed explanation.

3. Run the setup function

  • Next, go to Run > Run Function > initialSetup to run this function.
  • In the Authorization Required dialog, click on Review Permissions.
  • Sign in or pick the Google account associated with this projects.
  • You should see a dialog that says Hi {Your Name}, Submit Form to Google Sheets wants to...
  • Click Allow

4. Add a new project trigger

  • Click on Edit > Current project’s triggers.
  • In the dialog click No triggers set up. Click here to add one now.
  • In the dropdowns select doPost
  • Set the events fields to From spreadsheet and On form submit
  • Then click Save

5. Publish the project as a web app

  • Click on Publish > Deploy as web app….
  • Set Project Version to New and put initial version in the input field below.
  • Leave Execute the app as: set to Me([email protected]).
  • For Who has access to the app: select Anyone, even anonymous.
  • Click Deploy.
  • In the popup, copy the Current web app URL from the dialog.
  • And click OK.

IMPORTANT! If you have a custom domain with Gmail, you might need to click OK, refresh the page, and then go to Publish > Deploy as web app… again to get the proper web app URL. It should look something like….

6. Input your web app URL

Open the file named index.html. On line 12 replace <SCRIPT URL> with your script url:

<form name="submit-to-google-sheet">
  <input name="email" type="email" placeholder="Email" required>
  <button type="submit">Send</button>

  const scriptURL = '<SCRIPT URL>'
  const form = document.forms['submit-to-google-sheet']

  form.addEventListener('submit', e => {
    fetch(scriptURL, { method: 'POST', body: new FormData(form)})
      .then(response => console.log('Success!', response))
      .catch(error => console.error('Error!', error.message))

As you can see, this script uses the the Fetch API, a fairly new promise-based mechanism for making web requests. It makes a "POST" request to your script URL and uses FormData to pass in our data as URL paramters.

Because Fetch and FormData aren't fully supported, you'll likely want to include their respective polyfills. See section #8.

Fun fact! The <html>, <head>, and body tags are actually among a handful of optional tags, but since the rules around how the browser parses a page are kinda complicated, you'd probably not want to omit them on real websites.

7. Adding additional form data

To capture additional data, you'll just need to create new columns with titles matching exactly the name values from your form inputs. For example, if you want to add first and last name inputs, you'd give them name values like so:

<form name="submit-to-google-sheet">
  <input name="email" type="email" placeholder="Email" required>
  <input name="firstName" type="text" placeholder="First Name">
  <input name="lastName" type="text" placeholder="Last Name">
  <button type="submit">Send</button>

Then create new headers with the exact, case-sensitive name values:

A B C D ...
1 timestamp email firstName lastName

8. Related Polyfills

Some of this stuff is not yet fully supported by browsers or doesn't work on older ones. Here are some polyfill options to use for better support.

Since the FormData polyfill is published as a Node package and needs to be compiled for browsers to work with, a good option for including these is using Browserify's CDN called This service compiles, minifies and serves the latest version of these scripts for us.

You'll want to make sure these load before the main script handling the form submission. e.g.:

<script src=""></script>
<script src=""></script>
<script src=""></script>

  const scriptURL = '<SCRIPT URL>'
  const form = document.forms['submit-to-google-sheet']

Have feedback/requests/issues?

Please create a new issue. PRs are definitely welcome, but please run your ideas by me before putting in a lot of work. Thanks!

Related/Inspirational Articles


Popular Google Projects
Popular Form Projects
Popular Companies Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Fetch Api
Google Sheets
Html Form