Submitting a Google Form using the Command Line

TLDR: Use the tool at the bottom of this page 👇

I use Google Forms ALOT! On a normal day, I’m looking at 10 — 15 submissions to the same two forms: a personal expense tracking form, and a company expense tracking form.

The traditional process of opening the browser, typing in the URL, manually filling in the different fields and hitting Submit was getting incredibly annoying. I wanted a way to be able to submit a form in seconds, and without leaving whatever it was I was working on.

I needed a way to submit a form using the command line!

The Steps

Turns out, it’s actually pretty simple to do!

  1. Head over to your form URL and click on the “Edit” icon in the top-right:
  2. Click on the in the top-right, and select “Get pre-filled link”:
  3. Fill the form, and click “Get link”:
  4. You should now have a link that looks something like this:

    Now, we just need to make 2 changes (not needed if you’re using my fancy tool below):

    • Replace viewform with formResponse, and
    • Append &submit=Submit to the end of the URL

That’s it! You can paste that link into your browser, and you should see the familiar “Your response has been recorded” message.

An even easier way…

Of course, to actually use this in the command line, we need to use curl.

To make things easy for you, I created a neat little tool for this. Just paste your pre-filled link from above, and it’ll generate the curl command for you!

The Tool 🛠

Paste your pre-filled link below:

and… hey presto ✨

Your curl command is:

What I do

I then take the curl command above and add it to my .bash_profile like so:

# ~/.bash_profile
aed () {
  local amount=$1
  local category=$1
  local description="$*"

  curl -G -Ss \
    --data-urlencode "entry.1491423912=$category" \
    --data-urlencode "entry.1092687747=$amount" \
    --data-urlencode "entry.478624260=$description" \

Now, whenever I want to log an expense, I just do:

aed 10 shopping 1kg of frog legs

Couple this with Alfred, and the workflow becomes beautifully apt:

Logging Google form entry using the command line and Alfred

Comments? Hit me up on Twitter @yazinsai