JavaScript Compiler

Write JavaScript and run it. Your browser's own engine in a worker thread - no install, no account, nothing sent to a server.

← VizLearn
main.js JavaScript
Output

                

What this is

Your browser’s own JavaScript engine, running your code in a worker thread. Nothing is uploaded, and the page works fully offline.

console.log prints objects as JSON, arrays in full, and the print alias works too.

What works

  • Template literals, arrow functions, destructuring, async/await inside functions.
  • The whole language — this is the real engine, not a simulator.
  • An infinite loop is stopped after 10 seconds instead of freezing the tab.

What does not

  • document and window — there is no page here, so no DOM.
  • Top-level await — wrap it in an async function instead.
  • File system access, and input()-style prompts.

How it runs

Your browser already contains a fast JavaScript engine, so there is nothing to download and nothing to compile. The code runs in a worker thread rather than on the page, which means it cannot touch this document, and an accidental infinite loop stops the worker instead of freezing the tab.

Because it is the real engine, everything modern JavaScript has is here: let and const, arrow functions, destructuring, spread, classes, template literals, optional chaining, Map, Set, generators and modules-level syntax that does not need imports.

Asynchronous code

Promise, async and await all work, as do setTimeout and queueMicrotask. A top-level await is allowed, so you can write const x = await something() without wrapping it in a function.

This makes the lab a good place to settle what the event loop actually does. Log something before a promise, inside it, and after it, then predict the order before pressing Run. The result is usually not what people expect the first time, and seeing it is worth more than reading about microtask queues.

What the console shows

console.log, warn, error and info are captured and mirrored into the output panel, and print works as an alias. Objects and arrays are shown in full rather than as [object Object], which is the usual frustration when debugging in a plain terminal.

Errors arrive with their stack, and the three you will meet most are ReferenceError for a name that does not exist, TypeError for calling something that is not a function or reading a property of undefined, and SyntaxError for code that could not be parsed at all.

Things worth trying

  • Compare == with === across a few values and see exactly which coercions happen.
  • Log 0.1 + 0.2. Floating point is the same everywhere, and seeing it once explains a great many bug reports.
  • Order a mix of setTimeout, a resolved promise and plain statements, and predict the output before running.
  • Use map, filter and reduce on an array, then write the same thing as a loop and decide which reads better.

Looking for a language lab?

The Python compiler runs real CPython in the same spirit, and the SQL playground backs a real SQLite database.