Share a Google Colab notebook (open in the browser, press play)
Hand someone a notebook of Python they open in a browser tab and run by pressing play — no install, no setup on their side. The share works exactly like a Google Doc: it is a Drive file.
Time: the share itself is one click (or one sentence to your agent). Two un-delegable bits: anyone who runs the notebook needs their own free Google account, and if the code uses an API key, the recipient must paste in their own — secrets never travel with the notebook.
[confirmed]Last verified: 2026-06-07 · sharing, runtime, and Secrets behaviour come from Colab's own FAQ and Google Drive sharing help.[confirmed]
Before you begin
- A Google account. A Colab notebook is a Drive file (a
.ipynb), so it lives in Google Drive and shares through the same dialog as a Doc. Open or create one at colab.research.google.com. - The recipient's email — only for the named-people path. The "anyone with the link" path needs no email.
- For the agent path: the Google Drive tooling connected, so your agent can write the notebook file and drop it into your Drive. One-time auth, ~5 min. (The agent can place and copy the file; the share-dialog click is still yours — see below.)
New to letting an agent drive? Start with Set up Claude Code, then How to ask your agent; come back once claude runs.
The one thing to say
Have your agent build the notebook and put it in your Drive:
Write this as a Colab notebook (.ipynb) and put it in my Google Drive, then give me the link.
Your agent writes the cells and places the .ipynb in Drive via the Drive tooling. [confirmed] Opening it in Colab and setting who gets in is the part you do — that's a click in the Share dialog, below.
Share it (same dialog as a Google Doc)
Open the notebook in Colab and click Share (top-right). The dialog has two halves, identical to a Doc: [confirmed]
- Named people (top box) — type an email, pick a role, Send. The default is Restricted: only the people you list can open it. Each gets an email with the link.
- General access (the dropdown) — switch from Restricted to Anyone with the link, then pick the role. Now the link is the key — anyone can open it to view without a Google account.
[confirmed]
Click Copy link and send it wherever your recipient is.
Pick the right role — same three as a Doc: [confirmed]
- Viewer — read the code and saved output. Can't change anything.
- Commenter — read plus leave margin comments. Can't edit cells.
- Editor — read and edit the cells in your copy. The widest grant; hand it out deliberately.
Viewing ≠ running. None of the three roles lets someone run your cells in your notebook. To execute code they make their own copy (one click — below) or, as an Editor, edit yours. Running always needs them signed in to a Google account, because each run spins up a free machine tied to that account.
[confirmed]
How the recipient runs it
Once they open the link (signed in to any Google account):
- Make it theirs: click Copy to Drive (top-left toolbar), or File → Save a copy in Drive. This drops an editable copy in their Drive — yours stays untouched.
[confirmed] - Run a single cell: click the play triangle on the left of the cell, or press Shift+Enter. The first run connects them to a free machine (a few seconds).
[confirmed] - Run everything top to bottom: Runtime → Run all (or Ctrl/Cmd+F9).
[confirmed]
That's the whole flow for the recipient: open link → Copy to Drive → press play. No install, no terminal.
If the notebook needs an API key (Colab Secrets)
If your code reads a secret — from google.colab import userdata then userdata.get('OPENAI_API_KEY') — that secret does not travel with the notebook. Secrets live in the 🔑 Secrets tab on the left, stored against your Google account, and are stripped on share. [confirmed]
So the recipient must add their own:
- Open the 🔑 tab → Add new secret → set the Name to the exact same string your code expects (e.g.
OPENAI_API_KEY). - Paste their key into Value, and flip Notebook access on.
[confirmed]
Tell them which secret names to set, and that they need their own key — code that reads a missing secret errors on the line that calls userdata.get. There's no way to hand them a working key safely through the notebook itself; this friction is the point of Secrets.
If it doesn't work
- Recipient sees "You need access" / "Request access" → the notebook is still Restricted and they're not on the list. Add their email, or switch General access to Anyone with the link. If they request access, you get a one-click-approve email.
[confirmed] - They opened it but can't change or run anything → expected. A Viewer/Commenter link is read-only; they need to Copy to Drive first to get a runnable copy. As an Editor they can run yours directly.
[confirmed] - "Runtime disconnected" mid-run → Colab drops idle machines and caps free sessions at 12 hours max; the exact idle cutoff isn't published. Just Reconnect (top-right) and re-run — but note any variables and downloaded files from the old session are gone, so re-run from the top.
[confirmed](idle duration[unclear]— Colab's FAQ says runtimes "time out if you are idle" without a number, checked 2026-06-07) SecretNotFoundError/userdataerrors → the recipient hasn't added the secret, or named it differently. Match the name in the 🔑 tab exactly and toggle Notebook access on.[confirmed]- Cells run slowly / "do I need a GPU?" → almost certainly not. A GPU only helps for training or heavy ML; for ordinary scripts the default CPU runtime is fine and connects faster. Colab itself advises against requesting a GPU "when it is not needed." Leave Runtime → Change runtime type on the default.
[confirmed] - Output looks empty before they run → if you ticked Edit → Notebook settings → Omit code cell output when saving, saved output isn't shared; they'll see results only after running.
[confirmed]
Prefer to do it all by hand?
- In Colab, File → Save a copy in Drive (or you're already editing a Drive notebook) so the
.ipynbis in your Drive. - Click Share (top-right) → named people: type emails, set a role, Send. Or link: under General access, switch to Anyone with the link, set the role.
- Copy link → send it.
- If the code uses a key, tell the recipient which Secrets names to create with their own values.
Watch / read
Best written walkthrough: Colab's own FAQ — authoritative on "share via the Share button / Drive sharing instructions", what gets shared, runtime limits, and the GPU advice — paired with Google Drive sharing help for the exact Restricted-vs-link dialog and roles. For the API-key case, Stanford Libraries' Using Google Colab — API authentication is the clearest on "another user will need to add their own keys." [confirmed]
Short videos (under ~3 min; YouTube transcripts couldn't be verified from this machine this session, so titles/channels are the signal):
- Easily share Python Notebook with anyone on Google Colab — Amit Thinks — 1:51 — tight walk through the Share button and the anyone-with-link choice.
- Save and Share Google Colab File — NoRa SharK — 1:53 — pairs Save-a-copy / Copy to Drive with the share step, which is the recipient's exact path.
- Google Colab - Sharing Notebooks! — Adrian Dolinay — 4:45 — slightly longer, but the clearest on roles (view/comment/edit) for a first-timer.
Other ways to share
- They should just see results, not run code? → a Claude Artifact or a deployed website opens in any browser with nothing to run, no account.
- They'll build on the project as a set of files? → a GitHub repository hands over the whole thing with every version tracked.
- Want them to run it but in an even more turnkey, no-Google-account way? → share and run on Replit runs in the browser without a Google login.
Sources
- Colab FAQ — Google Colaboratory (share via Drive, what's shared, "omit code cell output", 12-hour free limit, runtimes time out when idle, avoid GPUs when not needed) — checked 2026-06-07
- Share files from Google Drive — Google Drive Help (Restricted vs Anyone-with-link, Viewer/Commenter/Editor, copy link, no-account viewing) — checked 2026-06-07
- Using Google Colab — Intro to API Authentication — Stanford University Libraries (Secrets manager,
userdata.get, recipients must add their own keys) — checked 2026-06-07 - Overview of Colaboratory Features — Google Colaboratory (play button to run a cell, Copy to Drive / Save a copy in Drive) — checked 2026-06-07
- Sharing Notebook in Google Colab — GeeksforGeeks (Viewer/Commenter/Editor on a notebook, shareable link) — (unofficial — GeeksforGeeks, seen 2026-06-07)