Google Apps Script

Overview of Google Apps Script

Google Apps Script is a scripting language based on JavaScript that lets you do new and cool things with Google Apps like Docs, Sheets, and Forms. There's nothing to install — we give you a code editor right in your browser, and your scripts run on Google's servers.

If you're new to JavaScript, Codecademy offers a great course for beginners. (Note that this course was not developed by and is not associated with Google.)

What can Apps Script do?

Apps Script is versatile. Among other things, you can:

For a quick demo of Apps Script in action, try one of our 5-minute quickstarts:

Your first script

The steps below show how to build and run a simple standalone script that creates a Google Doc and emails you a link.

Set it up

  1. Visit script.google.com to open the script editor. (You'll need to be signed in to your Google account.) If this is the first time you've been to script.google.com, you'll be redirected to a page that introduces Apps Script. Click Start Scripting to proceed to the script editor.
  2. A welcome screen will ask what kind of script you want to create. Click Blank Project or Close.
  3. Delete any code in the script editor and paste in the code below.

    function createAndSendDocument() {
      // Create a new Google Doc named 'Hello, world!'
      var doc = DocumentApp.create('Hello, world!');
    
      // Access the body of the document, then add a paragraph.
      doc.getBody().appendParagraph('This document was created by Google Apps Script.');
    
      // Get the URL of the document.
      var url = doc.getUrl();
    
      // Get the email address of the active user - that's you.
      var email = Session.getActiveUser().getEmail();
    
      // Get the name of the document to use as an email subject line.
      var subject = doc.getName();
    
      // Append a new string to the "url" variable to use as an email body.
      var body = 'Link to your doc: ' + url;
    
      // Send yourself an email with a link to the document.
      GmailApp.sendEmail(email, subject, body);
    }
    
  4. Select the menu item File > Save. Name your new script and click OK.

Try it out

  1. To execute the script, either click ▶ or select the menu item Run > createAndSendDocument.
  2. A dialog box will appear and tell you that the script requires authorization. Click Continue. A second dialog box will then request authorization for specific Google services. Read the notice carefully, then click Accept.
  3. A yellow bar at the top of the script editor will indicate when the script is running. When the yellow bar disappears, the script has finished.
  4. Check your Gmail inbox for the new email, then click the link to open the Google Doc you created.
  5. Open your Google Drive. You'll see that both the script and the document are stored there.

Learn more

To continue learning about Apps Script, take a look at the following resources:

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.