JavaScript Runner

Run JavaScript in a sandboxed iframe and view console output.

Run JavaScript snippets and read their console output without leaving the page. Code executes inside a sandboxed iframe with no access to this site, and a script that hangs is terminated after five seconds. It suits quick experiments, demonstrations and checking small algorithms.

What is a sandboxed JavaScript runner?

A runner executes code and captures its output. Running arbitrary code is risky, so this tool puts it in an iframe with sandbox=allow-scripts and without allow-same-origin. The code gets a unique opaque origin, so it cannot read this site's cookies, storage or page. console.log, info, warn and error are replaced by functions that post messages to the parent, which prints them in the Console with colors for each level. Uncaught errors and unhandled promise rejections are also shown. A 5 second timer removes the iframe if the code has not finished, which stops infinite loops. It is isolated but not a guarantee for everything: sandboxed code may still make network requests.

How to use JavaScript Runner

  1. Write the code Enter JavaScript in the editor.
  2. Run Press Run. The status shows Running... and then Finished.
  3. Read the console Output appears under Console, colored by level.
  4. Clean up Use Clear console to remove lines, or Reset sandbox to stop and clear everything.

Frequently asked questions

Can the code access my cookies or this page?

No. The iframe uses sandbox allow-scripts without allow-same-origin, so it has an opaque origin and cannot reach this site's cookies, storage or DOM.

Why was my script terminated?

If it has not finished within 5 seconds the iframe is removed. This stops endless loops but also long legitimate computations.

Is the code sent to a server?

No. It is placed in the sandboxed iframe on this page.

Does the sandbox block network requests?

Not necessarily. Code can still try fetch or other requests under normal browser rules, so avoid running code you do not trust.

Which console methods are supported?

log, info, warn and error. Each is displayed with its level color; other methods are not relayed.