JavaScript Code Runner
Write or paste JavaScript, press Run and read the console output next to your code. The script runs in an isolated worker inside your own browser, so it cannot touch this page or any server, and a time limit stops loops that never end.
- Runs in your browser
- No sign-up
- Free to use
Your code runs only in this browser tab, inside an isolated worker with no access to this page, its cookies or its storage. Nothing is sent to a server.
How to use JavaScript Code Runner
- Type or paste JavaScript in the editor, or load one of the examples.
- Press Run, or Ctrl + Enter while in the editor.
- Read the output of console.log, warnings and errors in the console pane.
- Adjust the code and run again; use Stop to cancel a long-running script.
JavaScript Code Runner features
Real engine
Your code is executed by the JavaScript engine of your browser, so modern syntax works exactly as it does there.
Sandboxed
The script runs in a worker inside a sandboxed frame with its own origin: no access to this page, cookies or stored data.
Infinite-loop protection
A watchdog ends the script when the time limit is reached, and the page stays responsive throughout.
Readable console
Objects, arrays, Maps, Sets, errors and console.table are formatted; warnings and errors are colour-coded.
Syntax errors located
The code is parsed before it runs, and a syntax error is shown with its line and column.
Async support
Promises, async functions, timers and top-level await all work.
When to use JavaScript Code Runner
- Trying out a snippet from documentation or an answer on a forum.
- Checking what an expression or array method really returns.
- Practising for an interview or working through a tutorial.
- Reproducing a small bug outside your project.
JavaScript Code Runner FAQ
Where does my code run?
In your browser only. The page creates a sandboxed frame, and inside it a Web Worker executes your script. The code is never sent to our server, and there is no server-side JavaScript execution at all.
Can the script access the page or my data?
No. The sandboxed frame has a separate, anonymous origin. The script cannot read this site's cookies or local storage, and a worker has no document or window to manipulate.
Why is there no document or window?
Workers do not have a DOM. That is part of what makes this runner safe and keeps the page responsive during heavy computation. For code that manipulates HTML, use the developer tools of your browser or a local file.
What happens with an infinite loop?
The loop runs in the worker, so the page does not freeze. When the time limit you selected is reached, the worker is terminated and a message tells you so. You can also press Stop at any time.
Does it support async code and modules?
Promises, async functions, timers and top-level await work. The import and export statements are not supported, because the runner executes one self-contained script and cannot load packages from the network.
Which JavaScript version is supported?
Whatever your browser supports. Current browsers implement the latest ECMAScript standard, including classes with private fields, optional chaining, BigInt and the newer array methods.
How to run untrusted code safely in a browser
Running code that someone typed into a web page is a classic security problem. Executing it on a server would require heavy isolation, since any mistake exposes the server itself. Executing it directly in the page would give the script the same powers as the page: it could read cookies, change what you see, or send requests in your name. This runner avoids both by using two isolation features that browsers provide.
The first is the sandboxed frame. A frame created with the sandbox attribute and without the same-origin permission is treated as coming from a unique origin that matches nothing else. Storage, cookies and same-origin requests of the host site are out of reach. The second is the Web Worker, a separate thread with no document and no access to the user interface. Your code is handed to a worker that is started inside that frame, and the only channel back to the page is a stream of text messages, which the page displays as plain text.
This arrangement also solves the infinite-loop problem. JavaScript on a page shares a thread with the interface, which is why a runaway loop freezes a tab. A worker has its own thread. The page stays interactive, measures the time, and removes the frame when the limit is exceeded, which ends the worker immediately. The same mechanism is behind the Stop button.
The console you see is a small replacement for the built-in one. It formats each argument, with nested objects and arrays, circular references, Maps and Sets handled, and sends the text to the page. Output is capped at a few thousand lines so that a loop printing endlessly cannot exhaust memory. Since the engine is your browser's own, behaviour and performance are identical to what the same code would do in a real application, apart from the missing DOM.