Coding

What Is GitHub Codespaces? How It Works, Cost and Limits

GitHub Codespaces is a development environment hosted in the cloud: GitHub runs it in a Docker container on a virtual machine, and you work in it from a browser, Visual Studio Code or GitHub CLI. You create one from a repository, branch or commit, and the editor, tools and code are ready without installing anything locally.

Codespaces is part of GitHub itself. If you are new to the platform, what GitHub is used for covers the basics, and what a Git repository is explains the thing a codespace is built from.

How GitHub Codespaces works

Each codespace is a Docker container running on a virtual machine that GitHub hosts. When you connect, you are placed inside the container, with only limited access to the VM underneath. The container always runs Linux. GitHub's docs say Windows and macOS are not supported operating systems for the remote development container.

The default image is Ubuntu Linux with popular languages and tools already installed. A repository can replace it with another Linux distribution or a custom setup, described in a file the repository carries (see the dev container section below).

You choose how big the VM is. The documented range goes from 2 cores, 8 GB of RAM and 32 GB of storage up to 32 cores, 128 GB of RAM and 128 GB of storage. Which sizes you see depends on the repository, your account and your location.

How to connect to a codespace

There are three ways in, and they all reach the same codespace:

  • A web browser. The editor loads as a page, so any computer with a modern browser works.
  • Visual Studio Code. Your desktop editor connects to the remote container, so you keep your usual window and shortcuts while the code and tools run in the cloud.
  • GitHub CLI. gh codespace code opens a codespace in VS Code, and gh codespace code --web opens it in the browser.

How to create a codespace

On github.com:

  1. Open the repository's main page and pick the branch from the branch dropdown.
  2. Click Code, then the Codespaces tab. A message at the bottom of the dialog tells you who will pay for the codespace.
  3. Click the plus icon to create it with default settings. For control over the options, click the options icon at the top right of the tab, choose New with options, and pick the branch, dev container configuration, region and machine type. Then click Create codespace.

With GitHub CLI, gh codespace create prompts for the repository, branch, dev container file (if there is more than one) and machine type. To skip the prompts, pass flags:

gh codespace create -r OWNER/REPO -b BRANCH --devcontainer-path PATH -m MACHINE-TYPE

-b accepts a branch or a full commit SHA, and without it the default branch is used. -m takes a machine type name such as basicLinux32gb.

What a dev container is

A dev container is the repository's description of its own development environment. It lives in a file called devcontainer.json, usually inside a .devcontainer folder at the repository root. A .devcontainer.json file at the root also works, and the name must begin with a period. According to GitHub's docs, the file defines a dev container that can include frameworks, tools, extensions and port forwarding.

The file is JSONC, so comments are allowed. This minimal example uses only keys that GitHub's documentation shows:

{
  // Use an existing image
  "image": "mcr.microsoft.com/devcontainers/javascript-node:1-16",

  // Add tools, libraries or runtimes here
  "features": {},

  // Applied as VS Code settings inside the codespace
  "settings": {}
}

Instead of image, you can point at a Dockerfile with "build": { "dockerfile": "Dockerfile" }.

Because the configuration is committed, everyone who opens the repository in a codespace gets the same setup. A repository can hold several configurations in subdirectories, as .devcontainer/SUBDIRECTORY/devcontainer.json, for different kinds of work. Nesting deeper than that is not supported. Without any configuration, a codespace uses the default Ubuntu image. You can also personalize your own codespaces with a public dotfiles repository or Settings Sync.

Stopping, starting and timeouts

Stopping a codespace ends its running processes but keeps your saved changes. They are there the next time you start it. Terminal history is kept, but the text currently visible in the terminal is not.

Ways to stop one:

  • On github.com/codespaces, open the ellipsis menu next to the codespace and choose Stop codespace.
  • In a terminal, run gh codespace stop and pick the codespace from the list.
  • In VS Code, open the Command Palette and run Codespaces: Stop Codespace.

Closing the browser tab does not stop it. A codespace stops on its own after a period of inactivity, which is 30 minutes by default. You can change that in your personal settings to any value from 5 minutes to 240 minutes (4 hours). GitHub's timeout page also describes a maximum lifetime of 12 hours for a codespace, regardless of the idle timeout setting.

To come back to it, click its name on the Your Codespaces page, run gh codespace code, or use Codespaces: Connect to Codespace in VS Code.

How much GitHub Codespaces costs

All personal accounts get a monthly quota of free compute time and storage. The figures below are from GitHub's billing page as of November 2026, so check it for current numbers.

PlanIncluded storage per monthIncluded compute per month
GitHub Free (personal)15 GB-month120 hours
GitHub Pro20 GB-month180 hours

Larger machines use the quota faster. Each machine type has an included usage multiplier equal to its core count: 2 for a 2-core machine, 4 for 4 cores, up to 32 for 32 cores. Past the quota, the listed compute prices are:

MachinePrice per hour
2 core$0.18
4 core$0.36
8 core$0.72
16 core$1.44
32 core$2.88

That is proportional to cores: $0.09 per core per hour by simple division. Storage costs $0.07 per GB-month and accrues hourly for as long as the codespace exists, whether or not it is running. It covers your files, loaded data, extensions, prebuilds and custom dev containers.

Two billing rules matter most in practice. Compute is charged only while a codespace is running, so a stopped codespace incurs only storage costs. And if you have used up the free quota with no payment method on file, usage is blocked rather than billed. If you want usage beyond the quota, you need payment details and a spending limit. Owners of Team and Enterprise organizations can pay for their members' codespaces instead.

Limits and trade-offs

  • Linux only. If your project needs Windows-only tooling, a codespace cannot host it.
  • Limited host access. You work inside a container, not the VM itself.
  • Size ceiling. The largest documented machine is 32 cores, 128 GB of RAM and 128 GB of storage.
  • It needs a connection. The environment runs remotely, so you need network access to reach it.
  • It is metered. Leaving large machines running burns through the free quota quickly, so stop codespaces you are not using.

Codespaces is for editing and running code. Automated builds and tests that run when you push are a separate feature, covered in what GitHub Actions is. Prebuilds, which GitHub generates using Actions runner compute, can draw from your included compute usage.

If a codespace will not do what you expect

If you cannot find the machine size you want in the create dialog, remember that the available types depend on the repository, your account and your location. If a codespace behaves differently from a teammate's, compare which dev container configuration each of you picked under New with options, since a repository can define several. If creation is blocked entirely, check the billing page for your account: an exhausted quota without a payment method stops new usage.

Frequently asked questions

Is GitHub Codespaces free?
Partly. As of November 2026, GitHub's billing docs list a monthly included quota for personal accounts: 120 hours of compute and 15 GB-month of storage on GitHub Free, and 180 hours and 20 GB-month on GitHub Pro. Beyond that you need a payment method on file, otherwise usage is blocked.
Does closing the browser tab stop a codespace?
No. A codespace keeps running after you close the tab and keeps incurring compute charges until it stops from inactivity. The default idle timeout is 30 minutes, or you can stop it yourself from github.com/codespaces or with gh codespace stop.
Can I run a codespace on Windows or macOS?
No. The remote development container always runs Linux, and GitHub's docs state that Windows and macOS are not supported operating systems for it. You can still connect from a Windows or macOS computer through a browser, Visual Studio Code or GitHub CLI.
Do I lose my files when a codespace stops?
No. Stopping ends running processes, but saved changes stay in the codespace and are there when you start it again. Commit and push anything important to the repository anyway, because the codespace is not a backup.

Sources