Visual Studio Code can connect to Google Colab through an extension, but the setup differs from running Colab in a browser
Google Colab runs natively in your browser at colab.research.google.com, but you can also access it from Visual Studio Code using the Colab extension. The extension lets you write and run Colab notebooks inside VS Code instead of switching between applications. However, this is not the same as running Jupyter notebooks locally — you are still connecting to Google's servers, and you still need a Google account and internet connection.
The most straightforward path is to install the official Colab extension from the VS Code marketplace, sign in with your Google account, and then open or create a notebook file. The extension handles authentication and syncs your work with Google Drive.
Key Takeaways
- The Colab extension for VS Code is published by Google and installs directly from the VS Code marketplace in under a minute.
- You must sign in with a Google account that has access to Google Drive, since Colab notebooks are stored there by default.
- Notebooks open in VS Code still run on Google's servers, not your local machine, so you need an active internet connection.
- You can create new notebooks from within VS Code or open existing ones from your Google Drive.
Install the Colab extension from the VS Code marketplace
Open Visual Studio Code and go to the Extensions panel on the left sidebar (or press Ctrl+Shift+X on Windows/Linux, Cmd+Shift+X on Mac). Search for "Colab" and look for the extension published by Google. Click Install.
The extension is small and installs in seconds. Once installed, you will see a Colab icon in the left sidebar. You do not need to restart VS Code.
Sign in with your Google account
Click the Colab icon in the left sidebar. You will see a prompt to sign in. Click the sign-in button and your browser will open to a Google login page. Log in with the Google account you use for Google Drive and Colab.
After you sign in, the browser will show a confirmation message and return you to VS Code. The extension now has permission to access your Google Drive and create or open notebooks. If you have multiple Google accounts, make sure you sign in with the one where your Colab notebooks are stored.
Create a new notebook or open an existing one
In the Colab sidebar, you will see options to create a new notebook or browse your Google Drive. Click "Create new notebook" to start fresh, or click "Open notebook" to find one you have already created. New notebooks are saved to your Google Drive automatically.
When you open a notebook, it appears in the VS Code editor. You can write code in cells, add text and markdown, and run cells individually or all at once. The interface is similar to the browser version of Colab, but integrated into VS Code.
Run code and manage cells
Each cell in a Colab notebook can hold code or markdown text. To run a code cell, click the play button next to it or press Ctrl+Enter (Cmd+Enter on Mac). The code runs on Google's servers, and output appears below the cell.
You can add new cells by clicking the plus button in the toolbar or using the keyboard shortcut. Cells run in order, so if a later cell depends on variables or imports from an earlier one, you must run the earlier cell first. The extension shows you which cells have been run and which have not.
Understand what runs locally and what runs on Google's servers
The VS Code editor itself runs on your computer, but the actual code execution happens on Google's servers. This means you can use GPU and TPU resources without owning that hardware, but it also means you cannot run code offline or access files on your local machine directly.
If you need to work with local files, you can upload them to Colab using the file browser in the notebook, or mount your Google Drive and access files stored there. The extension does not change this behavior — it is still Colab running in the cloud.
Troubleshoot common issues
If the sign-in does not work, make sure you have allowed VS Code to access your Google account. Check that your Google account has permission to use Colab (most accounts do, but some organizations restrict it). If you see an error about authentication, try signing out and signing back in.
If notebooks do not appear in the "Open notebook" list, check that they are stored in your Google Drive and that you signed in with the correct Google account. Notebooks created in the browser version of Colab at colab.research.google.com will show up in the extension if they are in your Drive.
Frequently Asked Questions
Do I need to install Jupyter or Python locally to use Colab in VS Code?
No. Colab runs entirely on Google's servers, so you do not need Python or Jupyter installed on your machine. The extension is just a client that connects to Colab. You only need VS Code and an internet connection.
Can I use Colab in VS Code offline?
No. Colab requires an active internet connection because your code runs on Google's servers, not your computer. If you want to work offline, you would need to use Jupyter notebooks installed locally instead.
Are notebooks created in VS Code saved to Google Drive automatically?
Yes. When you create or edit a notebook in the Colab extension, it syncs to your Google Drive. You can also open the same notebook in the browser version of Colab at colab.research.google.com and see your changes.
Can I use the Colab extension without a Google account?
No. Colab requires a Google account to authenticate and store notebooks on Google Drive. If you do not have a Google account, you can create one for free at google.com.
What if I prefer to use Jupyter notebooks locally instead?
You can install Jupyter and Python on your machine and run notebooks locally without using Colab. This gives you full control over your environment but means you cannot use Google's free GPU resources. Both approaches work in VS Code with the appropriate extensions.