Run code in sandbox

When the user wants to run, execute, or test a code snippet in Python, JavaScript, Bash, C, or 60+ other languages — reach for Judge0 CE. Sandboxed execution returning stdout, stderr, and exit status. No auth required.

run-code-in-sandbox · v1 · updated 2026-04-16

Agents: This page is a SKILL.md-style capability guide. For JSON, call GET /api/skills/run-code-in-sandbox. To drop this into a local Claude Code install, copy the frontmatter + body below into ~/.claude/skills/run-code-in-sandbox/SKILL.md.

When to use this skill

When the user asks to run a code snippet, execute source code, or check what a program outputs — in any of 60+ languages — reach for Judge0 CE. It is a sandboxed code runner: POST base64-encoded source code with a language_id, get a token, then poll for stdout, stderr, and an exit status. For file I/O, network access, or long-running processes, use a different tool — the sandbox disables networking and caps wall-clock time at 10 seconds.

Your best first call

curl -X POST "https://ce.judge0.com/submissions?base64_encoded=true" \
  -H "Content-Type: application/json" \
  -d '{"source_code": "cHJpbnQoIjQyICsgMTcgPSIsIDQyICsgMTcp", "language_id": 71}'

No auth. No key. The Content-Type header is required — Judge0 ignores the body without it. source_code must be base64-encoded when ?base64_encoded=true is in the query string; the example above is print("42 + 17 =", 42 + 17) in Python 3 (language_id 71).

The POST returns a token:

{"token": "abc123-def456-..."}

Poll GET /submissions/{token} until status.id is no longer 1 (In Queue) or 2 (Processing). Status 3 means the program ran successfully; status 6 means a compilation error; status 11 (NZEC) is the most common failure for scripts that exit non-zero or throw an unhandled exception. The full status table is at GET /statuses.

Key fields in the poll response:

If you do not know the language_id, look it up first:

curl "https://ce.judge0.com/languages"

That returns an array of {id, name} objects. Python 3.8.1 is 71, Bash 5.0.0 is 46, C (GCC) has five entries from version 7.4.0 through Clang 19.1.7.

Fallbacks (when the best first call isn't enough)

Pitfalls

One-line summary for the user

I can run code snippets in 60+ languages on Judge0 CE — no auth, no setup — returning stdout, stderr, and exit status, but the sandbox caps CPU at 5 seconds, memory at 256 MB, and disables networking.

APIs this skill uses

Judge0 CE · primary · verified

Judge0 CE - Online code execution system. A robust, scalable, and open-source online code execution system that can be used to build your own online judge or competitive programming platform.

Generated from

Judge0 CE tutorial Getting Started with Judge0 CE

SKILL.md source (frontmatter + body)
---
name: run-code-in-sandbox
description: When the user wants to run, execute, or test a code snippet in Python, JavaScript, Bash, C, or 60+ other languages — reach for Judge0 CE. Sandboxed execution returning stdout, stderr, and exit status. No auth required.
---

## When to use this skill

When the user asks to run a code snippet, execute source code, or check what a program outputs — in any of 60+ languages — reach for Judge0 CE. It is a sandboxed code runner: POST base64-encoded source code with a `language_id`, get a token, then poll for stdout, stderr, and an exit status. For file I/O, network access, or long-running processes, use a different tool — the sandbox disables networking and caps wall-clock time at 10 seconds.

## Your best first call

```bash
curl -X POST "https://ce.judge0.com/submissions?base64_encoded=true" \
  -H "Content-Type: application/json" \
  -d '{"source_code": "cHJpbnQoIjQyICsgMTcgPSIsIDQyICsgMTcp", "language_id": 71}'
```

No auth. No key. The `Content-Type` header is required — Judge0 ignores the body without it. `source_code` must be base64-encoded when `?base64_encoded=true` is in the query string; the example above is `print("42 + 17 =", 42 + 17)` in Python 3 (`language_id` 71).

The POST returns a token:

```json
{"token": "abc123-def456-..."}
```

Poll `GET /submissions/{token}` until `status.id` is no longer 1 (In Queue) or 2 (Processing). Status 3 means the program ran successfully; status 6 means a compilation error; status 11 (NZEC) is the most common failure for scripts that exit non-zero or throw an unhandled exception. The full status table is at `GET /statuses`.

Key fields in the poll response:

- `stdout`, `stderr` — program output (may be `null` on failure)
- `status.id`, `status.description` — exit status (3 = Accepted, 11 = NZEC, etc.)
- `compile_output` — compiler errors when `status.id` is 6
- `time`, `memory` — resource usage

If you do not know the `language_id`, look it up first:

```bash
curl "https://ce.judge0.com/languages"
```

That returns an array of `{id, name}` objects. Python 3.8.1 is 71, Bash 5.0.0 is 46, C (GCC) has five entries from version 7.4.0 through Clang 19.1.7.

## Fallbacks (when the best first call isn't enough)

- **Need to submit many snippets at once** → `POST /submissions/batch` accepts up to 20 submissions in one request. Use for grading or comparing outputs across languages.
- **Need sandbox limits before submitting** → `GET /config_info` returns CPU time, memory, and wall-time ceilings. Call once per session — the values are static until the instance restarts.
- **Need compile or run commands for a specific language** → `GET /languages/{id}` returns `compile_cmd` and `run_cmd`. Useful when you need to know whether a language compiles or interprets.

## Pitfalls

- **`source_code` must be base64-encoded when `?base64_encoded=true` is set.** Send raw source code with that flag active and Judge0 tries to decode garbage — the submission either fails or runs something unintended.
- **`memory_limit` is in kilobytes, not bytes or megabytes.** 256000 means 256 MB. Passing `memory_limit: 256` thinking megabytes kills your code instantly.
- **`?wait=true` is disabled on the public CE instance.** The `/config_info` field `enable_wait_result` tells you. When `false`, the POST always returns just a token — you must poll.
- **Language IDs shift between instances.** ID 71 is Python 3.8.1 on `ce.judge0.com`, but a self-hosted Judge0 instance may number languages differently. Always call `/languages` on the instance you are targeting.

## One-line summary for the user

I can run code snippets in 60+ languages on Judge0 CE — no auth, no setup — returning stdout, stderr, and exit status, but the sandbox caps CPU at 5 seconds, memory at 256 MB, and disables networking.

« Back to all skills