TypeScript

Run TypeScript 5.6.3 online

Transpile TypeScript with esbuild and execute it on Node 22 in a secure, isolated sandbox. No setup required.

main.ts
Output
Click "Run Code" to execute...

About TypeScript

TypeScript is a type-safe superset of JavaScript developed by Microsoft for enterprise-grade applications. It catches errors at compile time, provides better tooling through type inference, and compiles down to clean JavaScript.

Our sandbox accepts TypeScript 5.6.3 syntax, transpiles and bundles it with esbuild 0.24, and runs the result on Node 22. It does not run a separate full tsc type-checking pass.

Sandbox features

  • Secure execution with Docker + gVisor isolation
  • TypeScript 5.6.3 with fast esbuild transpilation
  • Sync/stream: Basic 30s, Pro 60s, Ultra/Mega 150s; async: Ultra 300s, Mega 600s
  • Stdin support for interactive programs
  • REST API for programmatic access
  • No setup or installation required

Use TypeScript with stateful sessions

Open a session once, then call execute repeatedly. Files written under /home/sandbox and packages added with the npm install endpoint persist between calls; each call starts a fresh process, so variables do not carry over. Ideal for code interpreters and iterative agents.

# 1. Create a session (PRO, ULTRA, or MEGA)
curl -X POST https://sandboxapi.p.rapidapi.com/v1/sessions \
  -H "X-RapidAPI-Key: $RAPIDAPI_KEY" \
  -H "X-RapidAPI-Host: sandboxapi.p.rapidapi.com" \
  -H "Content-Type: application/json" \
  -d '{"language":"typescript","idle_ttl":300}'
# → {"id":"sess_abc","language":"typescript",...}

# 2. Write a file in the session
curl -X POST https://sandboxapi.p.rapidapi.com/v1/sessions/sess_abc/execute \
  -H "X-RapidAPI-Key: $RAPIDAPI_KEY" \
  -H "X-RapidAPI-Host: sandboxapi.p.rapidapi.com" \
  -H "Content-Type: application/json" \
  -d '{"code":"import { writeFileSync } from 'fs'; writeFileSync('/home/sandbox/state.txt', '42')"}'

# 3. A later call reads it back: files persist, variables do not
curl -X POST https://sandboxapi.p.rapidapi.com/v1/sessions/sess_abc/execute \
  -H "X-RapidAPI-Key: $RAPIDAPI_KEY" \
  -H "X-RapidAPI-Host: sandboxapi.p.rapidapi.com" \
  -H "Content-Type: application/json" \
  -d '{"code":"import { readFileSync } from 'fs'; console.log(Number(readFileSync('/home/sandbox/state.txt', 'utf8')) * 2)"}'
Read the sessions docs →

Need more? Get API access

Integrate secure code execution into your own apps with our REST API. Basic includes 500 requests per RapidAPI subscription period.