Which is better, Cloudflare Sandbox or CodeSandbox?
It depends on how big the machine must be and where your app lives. For agents that mostly wait on a model, Runtime costs the least: $0.64 for a thousand one-minute runs, against $1.35 on Cloudflare and $2.48 on CodeSandbox. It stays below both with every CPU busy. Pick Cloudflare Sandbox for short runs inside a Workers app, near users. Pick the CodeSandbox SDK for machines up to 64 cores and 128 GB, or for 250 VMs running at the same time on its Scale plan.
At a glance
The Sandbox SDK is billed as Cloudflare Containers, whose rates appear here. CodeSandbox's rates come from Together's documentation of the CodeSandbox SDK. CodeSandbox is a Together company.
| Cloudflare Sandbox SDK | CodeSandbox SDK | Runtime | |
|---|---|---|---|
| Isolation | A container in its own VM | Firecracker microVM | Firecracker microVM, own kernel |
| CPU | $0.072 per active vCPU-hour | By VM size: Nano (2 cores, 4 GB) is $0.1486 an hour | $0.025 per vCPU-hour of measured CPU, with a small floor |
| Memory | $0.009 per provisioned GiB-hour; at least 3 GiB per vCPU | Inside the VM size | $0.0075 per reserved GiB-hour |
| Billing step | 10 ms of CPU | A minute, rounded up | By the second |
| Largest | 4 vCPUs, 12 GiB and 20 GB of disk | 64 cores and 128 GB | Up to 16 vCPUs and 64 GiB paid, chosen separately |
| At once | 1,500 vCPUs and 6 TiB of memory per account | 10 VMs on Build; 250 on Scale | 100 sandboxes on a paid account |
| Plan fee | Workers Paid, at least $5 a month | Build free; Scale $170 a month | None; prepaid credit from $10 |
| Snapshots, forks | Filesystem-only snapshots in public beta | Memory snapshot and restore | Files, memory and running processes |
Which is cheaper for short runs?
Cloudflare, by a wide margin. The shorter the run, the wider the gap. CodeSandbox bills a Nano VM at 10 credits an hour, $0.1486, and rounds each VM's time up to the next minute. So a 40-second run is billed as 60. Cloudflare meters CPU in 10 ms steps and prices memory and disk per second.
Shorten the example below to 40-second runs with the same 20 CPU-seconds of work. Then 1,000 of them cost $1.03 on Cloudflare, still $2.48 on CodeSandbox, and $0.47 on Runtime. The order changes only for busy work. With a fixed price per minute, CodeSandbox becomes the cheaper rival once a one-minute run uses more than about 76 of its 120 CPU-seconds.
Cost for the same job
For the full one-minute case: 1,000 runs on 2 vCPU, 60 seconds each, with 20 CPU-seconds of computing per run. CodeSandbox runs a Nano VM, which has 4 GB, and Runtime gets 4 GiB. Cloudflare's floor of 3 GiB per vCPU makes its smallest custom 2 vCPU shape 6 GiB. The disk is 12 GB, as in Cloudflare's example.
- CPU
- 1,000 × 20 s × $0.000020
- $0.40
- Memory
- 1,000 × 60 s × 6 × $0.0000025
- $0.90
- Disk
- 1,000 × 60 s × 12 × $0.00000007
- $0.05
- Size
- 1,000 × 60 s / 3,600 × $0.1486
- $2.48
- CPU
- 1,000 × 20 s / 3,600 × $0.025
- $0.14
- Memory
- 1,000 × 60 s / 3,600 × 4 × $0.0075
- $0.50
At 100,000 runs a month: $135.04 on Cloudflare, $247.67 on CodeSandbox, and $63.89 on Runtime. Keep both CPUs busy for the whole minute, and it is $1.33 on Runtime, $3.35 on Cloudflare and $2.48 on CodeSandbox. The Nano's price does not move at all. Cloudflare's figure assumes each sandbox is destroyed after its run. Plan fees, Workers requests, Durable Object time, storage, network and free allowances are excluded.
Is a microVM safer than Cloudflare's container?
Both put a virtual machine boundary around your code. Cloudflare runs each sandbox as a container inside its own VM. CodeSandbox and Runtime run each sandbox as a Firecracker microVM with its own Linux kernel. MicroVM vs container explains the difference, and Firecracker explains what the microVM is.
On Runtime, root inside the sandbox cannot change its network, CPU, memory or cost. A sandbox can run with its internet off or with an allow list. See how to turn off sandbox internet.
Which one to pick
- Short, bursty runs inside a Workers app: Cloudflare Sandbox, which also places sandboxes near users on its network.
- Big machines or a large fleet: the CodeSandbox SDK, with VMs up to 64 cores and 128 GB, memory snapshots, and up to 250 VMs on the Scale plan.
- Per-second billing for an agent that waits: Runtime. Its measured CPU costs 65% less than Cloudflare's rate. It offers any mix of vCPUs and memory, and forks that copy a running sandbox, including its memory.
Moving the code
Cloudflare's 0.x calls have direct equivalents. getSandbox(env.Sandbox, name)
maps to Sandbox.getOrCreate(name), sandbox.exec(cmd) maps to exec, and
proxyToSandbox maps to box.previews.create(port). Once ported, the code no
longer has to live in a Worker. With CodeSandbox, start a Runtime sandbox
where you started a VM, send commands through exec, and call stop() where
the VM was shut down.
TypeScriptimport { Sandbox } from "withruntime";const box = await Sandbox.create();try { await box.files.write("/workspace/invoice.py", "print(sum([125, 250, 375]))\n"); console.log((await box.exec("python3 /workspace/invoice.py", { check: true })).stdout);} finally { await box.stop();}A coding agent given the instruction in migration will do the port on a branch and test it on the free usage. Credit you add within 30 days of signing up is matched, up to $1,000 in total. Full comparisons: Runtime vs Cloudflare, Runtime vs CodeSandbox.
Runtime Cloud
Runtime costs 53% less than Cloudflare and 74% less than CodeSandbox for the same agent job. A thousand one-minute runs at 2 vCPU cost $1.35 on Cloudflare, $2.48 on CodeSandbox and $0.64 on Runtime. Runtime counts measured CPU second by second. It never rounds a run up to a whole minute, and it takes any mix of vCPUs and memory you ask for. Rates checked 25 October 2026.
An account takes one command, npx withruntime login, and the free usage needs no card. Existing code follows the migration guide.
Sources
Cloudflare sandbox lifetime, snapshot behavior checked 25 October 2026. Rates checked 25 October 2026; Cloudflare's sandbox lifecycle page read 26 October 2026.
Cloudflare Containers pricing, Containers limits and instance types, Containers architecture
Facts on this page were checked on 26 October 2026.