Skip to content
ToolMug

Run JavaScript Online

Paste or write JavaScript and click Run to see console.log, warn and error output — for trying snippets, practising algorithms or debugging a bit of logic. Top-level await works, and code runs in a separate worker, so an infinite loop won't freeze the page.

Runs in your browser — nothing you enter is uploaded

Ctrl+Enter / ⌘+Enter

Console

Output from console.log appears here.

Runs in a separate worker: no DOM (document, window), but fetch, timers, JSON, Intl and other built-ins work.

How to use

  1. Write code on the left, or edit the example.
  2. Click Run or press Ctrl+Enter (⌘+Enter on Mac). Console output appears on the right.
  3. If code runs too long, click Stop, or set the time limit at the bottom right.

Options explained

Environment
A Web Worker in your browser, with the latest JavaScript syntax your browser supports, fetch, setTimeout, Intl and crypto, but no document or window.
Console
console.log, info, warn, error, debug, table, count and time/timeEnd, with %s, %d and %o placeholders. Objects are expanded much like in Node.js.
Top-level await
The code runs inside an async function, so you can use await directly.

What gets printed

Only what you send to the console appears in the output. The value of the last line is not shown as it would be in a browser console, so wrap it in console.log. Printing follows Node.js style: arrays and objects are expanded, strings inside them are quoted, and the placeholders %s and %d are filled from the following arguments.

console.log([1, 2, 3].map((n) => n * n));
console.log('%s is %d years old', 'Ada', 36);
console.log({ name: 'Ada', tags: ['a', 'b'] });
const data = await fetch('https://example.com/').then((r) => r.status);
console.log(data);

The first three lines print [ 1, 4, 9 ], Ada is 36 years old and { name: "Ada", tags: [ "a", "b" ] }. The last two lines need a network connection and print the HTTP status of the request. The time limit can be set to 5, 10, 30 or 60 seconds; when it is reached, the run is ended and a message says so.

Frequently asked questions

Can I import npm packages?

Not with import statements. You can load ESM packages dynamically with await import('https://esm.sh/package-name'), which needs a network connection.

What if I write an infinite loop?

Click Stop to end it immediately, or it stops automatically at the time limit. Each run uses a fresh worker, so the page is not affected.

Is my code uploaded?

No. It runs only in your browser; the only network requests are ones your own code makes.

Is TypeScript supported?

Only JavaScript for now; remove TypeScript type annotations first.

Privacy

This tool runs entirely in your browser. Your files and text are processed on your device and are never uploaded to our servers.

Related tools