How the JavaScript Playground Runs Code
AnyTool runs user JavaScript inside a freshly created sandboxed iframe (sandbox="allow-scripts" only, with no same-origin) so the code cannot read the parent page, cookies, or local storage. A bootstrap overrides console.log/warn/error/info/debug and wraps the source in an async IIFE, then posts each result back to the editor via postMessage, so the leveled console streams output live and supports top-level await, Promises, and timers. Execution runs as you type with debounced auto-run, runtime errors are mapped back to source line and column numbers, and optional TypeScript transpile (ts.transpileModule) and Prettier formatting use bundled libraries. Nothing is sent to a server and there is no runtime CDN.
- Code runs in a sandboxed allow-scripts iframe — no server execution
- Leveled live console with pretty-printed objects and error line numbers
- Run-as-you-type with debounced auto-run; async/await via an async IIFE
- Optional in-browser TypeScript transpile and one-click Prettier formatting
- Examples library and share-via-URL with state encoded in the link, no backend
