E2B vs CodeSandbox: pricing, isolation and limits
Both run Firecracker microVMs. E2B bills vCPUs and memory by the second; CodeSandbox bills a fixed VM size by the minute, rounded up.
Runtime runs the same job for 77% less than E2B and 74% less than CodeSandbox. 1,000 one-minute runs of a 2 vCPU, 4 GiB sandbox cost $2.76 on E2B, $2.48 on a CodeSandbox Nano VM and $0.64 on Runtime. Runtime bills the CPU your code uses, by the second, and has no plan to buy for more than ten sandboxes at once. Rates checked 23 September 2026.
Estimated compute cost
77% less than E2B74% less than CodeSandbox
2 vCPUs · 4 GiB · 60 s a run · 20 CPU-seconds busy
Compute only, at list rates checked 23 September 2026 (E2B pricing, Together Code Sandbox). Plan fees, network, taxes and free credits are left out. The worked example below shows the arithmetic.
At a glance
CodeSandbox's rates are from Together's documentation of the CodeSandbox SDK; CodeSandbox is a Together company.
| E2B | CodeSandbox SDK | Runtime | |
|---|---|---|---|
| Isolation | Firecracker microVM, own kernel | Firecracker microVM | Firecracker microVM, own kernel |
| Price | $0.0504 per vCPU-hour, $0.0162 per GiB-hour | Credits by VM size; Nano (2 cores, 4 GB) $0.1486 an hour | $0.025 per vCPU-hour of measured CPU, $0.0075 per GiB-hour |
| Billing unit | Per second | Per minute, rounded up | Per second |
| Sizes | 1 to 8 vCPUs and 1 to 8 GiB, set apart | Fixed sizes from Pico to XLarge, up to 64 cores and 128 GB | vCPUs and memory chosen per sandbox |
| Plan fee | Hobby $0; Pro $150 a month | Build free; Scale $170 a month | None; prepaid credit from $10 |
| At once | 20 on Hobby, 100 on Pro, more as add-ons | 10 VMs on Build, 250 on Scale | 8 on the trial, 100 paid to start, raised on request |
| Free start | $100 of usage credit, once | The free Build plan | 50 sandbox hours, no card |
| Session length | 1 hour on Hobby, 24 hours on Pro | Not stated in the pricing docs | Leases of up to an hour, extended as often as needed |
| Saved state | Pause keeps files, memory and processes | Memory snapshot and restore; resume or clone in about 3 s | Pause, snapshots and forks keep memory and processes |
Is CodeSandbox cheaper than E2B for AI agents?
Slightly, for runs that last whole minutes. A Nano VM, 2 cores and 4 GB, is 10 credits an hour at $0.01486 a credit: $0.1486 an hour. The same size on E2B is 2 × $0.0504 plus 4 × $0.0162, $0.1656 an hour. Both charge that whether the code is working or waiting.
Short runs change the answer. CodeSandbox counts VM time in whole minutes, rounded up, and E2B bills by the second. 1,000 runs of 40 seconds each cost $1.84 on E2B and still $2.48 on CodeSandbox, because each one is billed as a full minute. For agents that start a sandbox, run one command and stop it, that rounding decides the bill.
The other differences are sizing and concurrency. E2B lets you set vCPUs and memory separately up to 8 each. CodeSandbox sells fixed sizes, much larger at the top end, and more than 10 VMs at once needs the $170-a-month Scale plan; E2B's Hobby plan allows 20 at once and Pro 100.
Runtime bills by the second, like E2B, and bills only the CPU a run uses. The same 1,000 runs of 40 seconds cost $0.47 on Runtime.
Cost for the same job
1,000 runs of a 2 vCPU, 4 GiB sandbox (a Nano VM on CodeSandbox). Each run lasts 60 seconds and keeps the CPU busy for 20 CPU-seconds: an agent that mostly waits for a model.
TextE2B CPU 1,000 × 60 s / 3,600 × 2 × $0.0504 = $1.68 Memory 1,000 × 60 s / 3,600 × 4 × $0.0162 = $1.08 Total $2.76CodeSandbox Size 1,000 × 60 s / 3,600 × $0.1486 = $2.48Runtime CPU 1,000 × 20 s / 3,600 × $0.025 = $0.14 Memory 1,000 × 60 s / 3,600 × 4 × $0.0075 = $0.50 Total $0.64At 100,000 runs a month that is $276.00 on E2B, $247.67 on CodeSandbox and $63.89 on Runtime. With both CPUs busy for the whole minute, it is $1.33 on Runtime against $2.76 on E2B and $2.48 on CodeSandbox, so Runtime is cheaper however busy the sandbox is. Each run is a whole minute here, so CodeSandbox's rounding adds nothing. Plan fees, storage, network and free credits are left out.
Which one to pick
- Pick E2B for per-second billing on sandboxes you size yourself, 20 sandboxes at once on a free plan, or a runtime you can self-host under Apache-2.0.
- Pick CodeSandbox for very large VMs, up to 64 cores and 128 GB, Dev Container support, or 250 VMs at once on a single plan.
- Pick Runtime for per-second billing on measured CPU at under a quarter of either price, 100 sandboxes at once with no plan fee, and forks that copy a running sandbox with its memory.
Switch from either one
From E2B, Runtime's SDK runs your code after one import change:
TypeScriptimport { Sandbox } from "withruntime/e2b"; // was: from "e2b"Pythonfrom withruntime.e2b import Sandbox # was: from e2b import SandboxFrom CodeSandbox, map the usual calls: create a sandbox with
Sandbox.create(), run commands with exec, move files with files.write and
files.read, and end it with stop(). A VM you hibernate becomes a sandbox you
pause() and wake(), and a fork from a template becomes fork, which copies
a running sandbox with its memory:
TypeScriptimport { Runtime, Sandbox } from "withruntime";const runtime = new Runtime();await using base = await Sandbox.create();await base.exec("pip install --quiet requests");const [a, b] = await base.fork({ count: 2 }); // both running, answered togetherawait Promise.all([a!.stop(), b!.stop()]);// Or keep the machine to start copies from later:const snapshot = await base.snapshot({ name: "with-requests", retentionDays: 7 });await using later = await runtime.sandboxes.create({ snapshot: snapshot.id });await runtime.snapshots.delete(snapshot.id);Or give your coding agent the one instruction in migration: it switches the project on a branch, tests it on the free trial and reports the monthly saving. The full side-by-sides are Runtime vs E2B and Runtime vs CodeSandbox; what a sandbox fork is covers forks in more depth.
Sources
E2B pricing and Together's Code Sandbox documentation rechecked 25 September 2026; the rest checked 23 September 2026.
- E2B pricing, E2B sandbox persistence
- Together Code Sandbox, CodeSandbox SDK pricing
- Runtime pricing and the JavaScript guide
Facts on this page were checked on 25 September 2026.