JavaScript Sandbox
Runs a snippet in a disposable worker and shows everything it logged and returned.
Loading the tool…
How to use this tool
- Paste the snippet, or load a .js file with the picker.
- Use console.log for anything you want to see, and return a value at the end if you want it printed.
- Raise the timeout if the snippet does real work; leave it low while you are still experimenting.
- Select Run in the sandbox. The worker is discarded afterwards, so nothing carries over to the next run.
What javascript sandbox does
Most online JavaScript runners send your code to a server. This one does not, and cannot — there is no server. The snippet is compiled inside a Web Worker created from a Blob in your own browser. A worker has no document, no window, no cookies and no view of this page, so nothing you paste can read or change anything on the site. On top of that, the worker bootstrap removes fetch, XMLHttpRequest, WebSocket, EventSource and importScripts before your first line is compiled, so a snippet cannot send what it sees anywhere either.
Every run gets a fresh worker and the worker is terminated afterwards, so nothing carries over between runs. console.log, console.warn and console.error are captured and formatted the way a developer console would show them — objects expanded, functions named, circular references marked rather than crashing the output — and the value your snippet returns is printed at the end. If the snippet never finishes, it is stopped at the timeout you set: a worker cannot be interrupted from outside, so terminating it is the only honest way to end a loop that never ends.