Online JavaScript Compiler

Run JavaScript instantly in a sandboxed worker with console output, async/await and modern ES2024 features. No sign-up, nothing to install.

ES2024 (your browser's engine) · Runs in your browser, so your code never reaches our servers.
main.jsJavaScript
Output

            
        
Ctrl/⌘ + Enter to run

How to use the online JavaScript compiler

  1. Write or paste your JavaScript into the editor. You can restore the starter example with Reset example.
  2. Press Run or use Ctrl + Enter (⌘ + Enter on a Mac).
  3. Output from console.log, console.info and console.debug appears in the Output panel. console.warn, console.error and uncaught exceptions, including their stack traces, are highlighted as errors.
  4. Choose a time limit of 5, 15 or 60 seconds. A script that runs longer is stopped automatically, and you can press Stop whenever you like.

There is nothing to download. JavaScript runs on the engine already built into your browser, so the page is ready immediately. Use Copy or main.js to save your code.

Your code runs locally, in a Web Worker in your own browser. It is never uploaded or stored on our servers. The editor remembers your last code in your browser's local storage, and in no other place.

What's supported

  • Modern JavaScript: everything your browser supports, including classes, arrow functions, destructuring, optional chaining (?.), nullish coalescing (??), BigInt, Map/Set and newer array methods.
  • Top-level await: your code is wrapped in an async function, so you can await promises directly.
  • Timers and promises: setTimeout, setInterval, Promise.all and similar functions work. The run is considered finished when your top-level code (including any awaited work) completes.
  • Worker-safe Web APIs such as JSON, Intl, TextEncoder, crypto.getRandomValues and structuredClone.

Limitations:

  • No DOM. The code runs in a worker, so document, window and alert() are not available.
  • No import/require. This is not Node.js, so npm packages and Node modules like fs cannot be loaded.
  • console.table prints its data as JSON rather than as a drawn table.
  • Behaviour follows the browser you are using. Very new features may be missing in older browsers.

JavaScript quick reference

const scores = { ada: 91, linus: 78, grace: 85 };

const passed = Object.entries(scores)
  .filter(([, s]) => s >= 80)
  .map(([name, s]) => `${name}: ${s}`);

console.log(passed);           // ["ada: 91", "grace: 85"] as JSON

const sleep = ms => new Promise(r => setTimeout(r, ms));
await sleep(100);
console.log(scores.bob ?? 'no score');
TaskSyntax
Declare variablesconst x = 1; let y = 2;
Arrow functionconst add = (a, b) => a + b;
Template literal`Total: ${sum}`
Strict equalitya === b
Destructuringconst { id, name } = user;
Wait for a promiseconst data = await promise;

Tips

  • Objects and arrays are printed as indented JSON. Log them directly, for example console.log({ a, b }), to see variable names next to their values.
  • Map and Set are printed with their size and contents (for example Map(2) [...]), and BigInt values with an n suffix.
  • Copy JSON output into the JSON formatter to validate it, or to collapse and explore large structures.
  • To tidy messy or minified code, run it through the JavaScript formatter before pasting it here.
  • Values attached to globalThis persist between runs until you press Stop. Variables declared with const or let do not.
Tip: Want type annotations? The online TypeScript compiler works the same way and also shows the JavaScript it generates.

Frequently asked questions

Which JavaScript version does this run?

Whatever your browser's engine supports: V8 in Chrome and Edge, SpiderMonkey in Firefox, or JavaScriptCore in Safari. Current versions of all of them support modern ECMAScript, including ES2024 features.

Why is document undefined?

To keep the page responsive and safe, your code runs in a Web Worker, which has no access to the page. Use this tool for logic, algorithms and data processing, not for DOM manipulation.

Can I use npm packages?

No. import, require and Node.js built-ins are not available. Only the language and the standard Web APIs that workers provide can be used.

What happens if I write an infinite loop?

The page stays responsive, because the loop runs in a worker. When the time limit is reached, or when you press Stop, the worker is shut down and your code stops.

Copied to clipboard