Modal vs CodeSandbox: pricing, isolation and limits
Modal runs sandboxes under gVisor, billed per second on the request; CodeSandbox runs Firecracker VMs in fixed sizes, billed by the minute.
Runtime charges 84% less than Modal and 74% less than CodeSandbox for one job, and it is also the only one of the three that bills by use. 1,000 one-minute runs of a 2 vCPU, 4 GiB sandbox cost $3.97 on Modal, $2.48 on CodeSandbox and $0.64 on Runtime. Modal and CodeSandbox charge for the whole machine as long as it is up. Runtime counts the CPU the code spends, per second, inside a Firecracker microVM with its own kernel. Rates checked 23 September 2026.
Estimated compute cost
84% less than Modal74% less than CodeSandbox
2 vCPUs · 4 GiB · 60 s a run · 20 CPU-seconds busy
Compute only, at list rates checked 23 September 2026 (Modal pricing, Together Code Sandbox). Plan fees, network, taxes and free credits are left out. The worked example below shows the arithmetic.
At a glance
On Modal, 2 vCPUs are one physical core, its billing unit. CodeSandbox's rates are from Together's documentation of the CodeSandbox SDK; CodeSandbox is a Together company.
| Modal Sandboxes | CodeSandbox SDK | Runtime | |
|---|---|---|---|
| Isolation | gVisor, a user-space kernel that intercepts system calls | Firecracker microVM | Firecracker microVM, own kernel |
| CPU | $0.1419 per physical core-hour (2 vCPUs), request or use | 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.0240 per GiB-hour, request or use | Inside the VM size | $0.0075 per reserved GiB-hour |
| Billing unit | Per second | Per minute, rounded up | Per second |
| Shapes | CPU and memory requested per sandbox | Fixed sizes, up to 64 cores and 128 GB | vCPUs and memory chosen per sandbox |
| Plan fee | Starter $0 with $30 a month of compute; Team $250 a month | Build free, 10 VMs at once; Scale $170 a month | None; prepaid credit from $10 |
| At once | 100 containers on Starter; 5,000 on Team | 10 VMs on Build; 250 on Scale | 8 on the trial; 100 to start on a paid account |
| Keeping state | Filesystem snapshots; up to 24 hours a sandbox | Memory snapshot and restore | Pause, snapshots and forks with memory and processes |
Which is cheaper for short runs?
It turns on how long each run lasts. Modal bills by the second, but at $0.1419 a core-hour plus $0.0240 a GiB-hour, $0.2379 an hour for this size. CodeSandbox's Nano VM costs $0.1486 an hour, but each run is rounded up to a whole minute.
| 1,000 runs, 2 vCPU, 4 GiB, 20 CPU-seconds each | Modal | CodeSandbox | Runtime |
|---|---|---|---|
| 20-second runs | $1.32 | $2.48 | $0.31 |
| 40-second runs | $2.64 | $2.48 | $0.47 |
| 60-second runs | $3.97 | $2.48 | $0.64 |
Modal is cheaper for runs under about 38 seconds, and CodeSandbox for anything longer up to a minute. Runtime bills by the second with no one-minute minimum, and counts CPU as measured, so it is the cheapest at every length.
Cost for the same job
The 60-second row in detail. Modal runs the 2 vCPU, 4 GiB sandbox on one physical core; CodeSandbox uses a Nano VM at 10 credits an hour, $0.01486 a credit. Each of the 1,000 runs lasts 60 seconds and does 20 CPU-seconds of work.
TextModal CPU 1,000 × 60 s × 1 core × $0.00003942 = $2.37 Memory 1,000 × 60 s × 4 × $0.00000667 = $1.60 Total $3.97CodeSandbox 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.64A month of 100,000 runs: $396.60 on Modal, $247.67 on CodeSandbox, $63.89 on Runtime. The busy variant, both CPUs busy for the whole minute, costs $1.33 on Runtime, $3.97 on Modal and $2.48 on CodeSandbox, the rivals unchanged since both already charged for the full machine. Plan fees, storage, network and free credit are outside the figures.
User-space kernel or microVM?
Modal puts each sandbox under gVisor, which catches the sandbox's system calls and answers them from a kernel written to run in user space. CodeSandbox and Runtime both boot each sandbox as a Firecracker microVM, with its own Linux kernel behind hardware virtualization. For the trade-offs, see Firecracker vs gVisor and what is a microVM?.
Which one to pick
- Modal fits GPU sandboxes, large numbers of very short runs where per-second billing pays off, and teams already running Modal functions and scheduled jobs.
- CodeSandbox fits jobs that need a very large fixed machine, up to 64 cores and 128 GB, or a fleet of 250 VMs at once on Scale.
- Runtime fits agent sandboxes: a microVM each, at a sixth of Modal's price and about a quarter of CodeSandbox's, measured CPU by the second, 100 at once to start and no plan fee.
Porting from each
Modal's calls translate one for one, and no App is required:
modal.Sandbox.create(app=...) is Sandbox.create(), sb.exec(*args) is
exec, Sandbox.from_name is Sandbox.getOrCreate(name). CodeSandbox's
create, command, file read and write, and shutdown calls each have a single
Runtime counterpart in the migration table;
instead of picking a VM tier, you set vCPUs and memory per sandbox.
Pythonfrom withruntime import Sandboxwith Sandbox.create(funding="trial") as box: print(box.exec("python3 -c 'print(6 * 7)'", check=True).stdout)npx withruntime compare --from codesandbox reprices the sandboxes you ran
at CodeSandbox's rates next to Runtime's. For Modal users,
npx withruntime switch --from modal before the first top-up matches it with
credit, up to $100. A coding agent can do either port from the one instruction
in migration, working on a branch and testing on the free
trial. See Runtime vs Modal and
Runtime vs CodeSandbox.
Sources
Modal pricing and Modal Sandboxes pages rechecked 25 September 2026; the rest checked 23 September 2026.
- Modal pricing, Modal resources and billing, Modal Sandboxes, Modal security
- Together Code Sandbox, CodeSandbox SDK pricing
- Runtime pricing and security
Facts on this page were checked on 25 September 2026.