Skip to content
Devtoolry

Online JavaScript Compiler

Run JavaScript online in an isolated browser sandbox. See console output, errors and execution time instantly, with top-level await and stdin input.

Runs in your browser · Nothing uploaded · No sign-up

Something not working, or missing a feature? Send feedback

About the JavaScript Compiler

The JavaScript Compiler runs code in a fresh, isolated Web Worker with network access removed, so you can try snippets, algorithms and interview questions safely. console output, errors and timing appear instantly. Use it as an online JavaScript compiler or a quick JS runner: write code, click Run and execute JS online without Node.js or a browser console.

Your code runs in an isolated Web Worker in your browser, so it never leaves your device.

How to use the JavaScript Compiler

  1. Write or paste JavaScript (or start from the sample).
  2. Add input in the stdin box if your code reads it with prompt() or readline().
  3. Click Run and read the console output, errors and execution time.

Example

Read input and print results

Input

const name = readline() ?? 'world';
console.log(`Hello, ${name}!`);

const scores = [72, 95, 88];
const average = scores.reduce((a, b) => a + b, 0) / scores.length;
console.log('Average:', average.toFixed(1));

Result

Hello, Ada!
Average: 85.0

With "Ada" in the stdin box. readline() returns one line of stdin per call and null when there are no more lines.

Common mistakes

  • import and require. Code runs as a single script without a module system, so import statements and require() are not available. Paste helper functions into the editor instead.
  • document and window. Code runs in a Web Worker, which has no page. DOM APIs such as document.querySelector are undefined; use the HTML Viewer for DOM experiments.
  • Undeclared variables. Code runs in strict mode, so assigning to a name without let, const or var throws a ReferenceError instead of creating a global.

Works well with the JavaScript Compiler

Frequently asked questions

Can my code make network requests?

No. fetch, XMLHttpRequest and WebSocket are disabled inside the sandbox, and each run has a time limit.

Which JavaScript version is supported?

Whatever your browser supports, which for current browsers includes the latest ECMAScript features such as top-level await inside async code.

Can I use await?

Yes. Your code runs inside an async function, so await works at the top level.

Is it Node.js?

No. It is your browser’s JavaScript engine, so Node APIs such as fs, process and Buffer are not available, but all standard language features are.

Is JavaScript compiled or interpreted?

Both, in a way. Engines such as V8 (Chrome, Node.js) and SpiderMonkey (Firefox) start running your code in an interpreter and compile frequently used functions to machine code just in time. There is no build step you run yourself, so an online JavaScript compiler simply runs your code.

How is this different from the browser console?

Each run starts in a fresh, isolated Web Worker, so variables from an earlier run don’t linger and the page, its cookies and storage are out of reach. Network access is removed, a stdin box feeds input to your program, and a time limit stops runaway loops.

How do I read input in JavaScript online?

Type it into the stdin box before you click Run. prompt() and readline() return one line at a time (null when the input runs out), and the stdin variable holds the whole input as a single string.

Guides and tutorials