Programming Languages
JavaScript Playground
Run modern JS - console.log, fetch, DOM APIs - in a sandboxed iframe.
Runtime: Sandboxed iframe
About this playground
Write and run modern JavaScript on this page. The runner uses a sandboxed iframe with postMessage to capture console.log / warn / error output - so anything you'd write in a browser console works here. Top-level await, ES modules, async / await, fetch, JSON, and timers are all available.
FAQs
Which JavaScript version?
Whatever your browser supports - typically the latest ECMAScript (ES2024+ in modern Chrome / Firefox / Safari). Top-level await and ESM imports both work.
Can I import packages from npm?
Use ESM CDNs like https://esm.sh/lodash-es or https://cdn.jsdelivr.net/npm/dayjs/+esm in a dynamic import. The runner doesn't bundle npm.
Is fetch() available?
Yes - the iframe can make CORS-allowed network requests. If you call an API that doesn't send permissive CORS headers, the request will fail (same as any browser fetch).
What about the DOM?
The iframe has its own document. You can document.body.append(...) to render elements, but they appear inside the hidden sandbox - the runner only relays console output. For visible DOM work use the HTML / CSS playground.
Is it safe to run any JS?
The sandbox uses 'allow-scripts' but no 'allow-same-origin', so your code can't read this page's cookies or localStorage. It can still consume CPU - infinite loops will hang the iframe (and the runner will warn after a few seconds).