What is a bound script in Google Sheets?

A bound script, also called a container-bound script, lives inside a specific spreadsheet file. You open it from Extensions > Apps Script and it travels with that workbook. getActiveSpreadsheet() works naturally because the script and sheet share one container. Most spreadsheet automations beginners build are bound scripts.

When to use it

Use a bound script when automation belongs to one workbook: custom menus, onEdit on that file, form responses tab, or a web app backed by that sheet data.

When to skip it

Choose a standalone script when one codebase must manage many spreadsheets by ID, or when you publish a workspace add-on not tied to a single file.

How it works

  1. 1

    Open Extensions > Apps Script from the target spreadsheet to create or edit the bound project.

  2. 2

    The script project ID is linked to this file in Drive, not floating alone in My Drive unless copied.

  3. 3

    Simple triggers onEdit and onOpen run in the context of this spreadsheet.

  4. 4

    Deploy web apps from the bound project; they usually read the parent sheet via getActiveSpreadsheet or openById on the parent.

  5. 5

    Copying the spreadsheet copies the script container, but verify triggers and authorizations after duplicate.

  6. 6

    clasp clone works on bound projects for local development with git.

Examples in Google Sheets

Custom Operations menu

onOpen in the bound script adds a menu to this workbook only, calling functions that format the active tab.

Invoice generator

Bound script reads line items from the same file, builds a PDF in Drive, and emails the customer.

Internal admin tool

A bound web app deployment serves managers a lookup UI over rows in the parent spreadsheet.

Better Sheets resources

Common mistakes

  • Expecting a bound script to see another file's active sheet without openById and permissions.
  • Duplicating the sheet for testing and forgetting triggers still point at old functions or accounts.
  • Mixing up two open files and editing the wrong bound script in another tab.
  • Moving the spreadsheet to a shared drive without checking who can edit the script project.
  • Assuming bound means private; editors of the sheet can usually open the script.

Frequently asked questions

What is the difference between bound and standalone scripts?
Bound scripts are attached to one spreadsheet or other Google file. Standalone scripts live as their own project in Drive and open files by ID.
How do I find my bound script?
Open the spreadsheet, then Extensions > Apps Script. That editor is the bound container.
Does the script copy when I copy the sheet?
Generally yes, the copy includes a script project. Triggers and authorizations may need setup again.
Can a bound script access other spreadsheets?
Yes with openById if the running account has permission to those files.
Can I detach a bound script?
You can copy code into a standalone project, but Google does not offer a simple detach button. Recreate as standalone if needed.
Who can edit a bound script?
Typically users with edit access to the parent spreadsheet, unless admin policies restrict Apps Script editing.
Is a bound script an add-on?
No. Add-ons are published separately. Bound scripts are private to the file unless you publish wider.
Does bound script work with Google Forms linked to the sheet?
Yes. Form submit triggers in the bound project run when responses arrive in the linked spreadsheet.

Related Tutorials

Watch how bound script works

Browse more tutorials
From Sheet to Script And Back Again - Learn to Code In Google Sheets Part 3

From Sheet to Script And Back Again - Learn to Code In Google Sheets Part 3

In this video, I'm going to share with you how to go basically from shee...
Now Do It Every Damn Day - Learn to Code in Google Sheets Part 5

Now Do It Every Damn Day - Learn to Code in Google Sheets Part 5

Now that we have a script that we wanna run every day, how do we run thi...
Embed a Number in a Website from a Google Sheet

Embed a Number in a Website from a Google Sheet

Ever wanted to display some data from a google sheet on your site? Witho...
Password Protecting Data In a Google Sheet

Password Protecting Data In a Google Sheet

A funky way to password protect some data in a sheet, 3 ways to do it: w...
Curate Google Sheets Easily - Automatic Bookmarklet Maker

Curate Google Sheets Easily - Automatic Bookmarklet Maker

Curated sites, articles, and more web resources super easily into a Goog...
Self Destructing Google Sheet

Self Destructing Google Sheet

Create a sheet that can trash itself. It can delete itself instantly or ...

Related blog posts

Guides that explain bound script in more depth.

Browse the blog

Related terms

Done reading about bound script?

Membership unlocks 637+ tutorials, unlimited generators, and every template. Practical lessons. Zero fluff.

Need this once

Jump to a free tool or a single tutorial for this topic.

Learning Sheets for real

Unlock the full library, generators, and templates with membership.