JavaScript Playground
Run JavaScript in your browser with live console output, interactive input, optional auto-run and a stoppable Web Worker.
JavaScript code
Monaco offers word suggestions (Ctrl + Space), plus JavaScript/TypeScript syntax and type diagnostics. Other languages have limited suggestions; check errors after Run. Suggestions need Monaco.
Console
Timing measures elapsed time, not CPU time; waiting for input is included. WASM memory, when available, is linear memory capacity, not total RAM or peak usage.
Output streams live, including timers. Use await prompt('Your name?') for interactive input. Runs in a Web Worker, without direct DOM access. Stop terminates execution; execution outside input waits is limited to 30 seconds, each answer can wait up to 2 minutes, and output is capped at 500 rows. Code can still make network requests, so only run code you trust. The tool does not save or upload your code or input.
Runtime details
JavaScript runs without downloading a language runtime.
Learn
About this tool
A console for trying JavaScript without leaving the page, built on the Monaco editor — the same editor that powers Visual Studio Code — so the code gets syntax highlighting, bracket matching, code folding and a formatter. Write or paste a snippet, press Run, and see everything it logs, the value it returns and how long it took. Monaco is a large bundle, so it is fetched from a CDN only when you press Enable Monaco; until then, and if the fetch fails, the page uses a plain text area with the same run, copy, download and clear actions. Output streams live from a Web Worker. Use await prompt() for interactive input. The tool does not save or upload code, but snippets can make network requests.Questions
- Why does the Monaco editor not appear straight away?
- Monaco is several megabytes, so loading it on every visit would slow the page down for people who only want a quick text box. It is fetched on demand when you press Enable Monaco. Until then a plain text area is used, and it keeps working if the fetch fails.
- Can I use top-level await?
- Yes. The snippet is wrapped in an async function, so await works at the top level and return gives back a value. That also means you do not need to wrap everything in an async IIFE yourself.
- Is the code sandboxed?
- Code runs in a disposable Web Worker. document, window and Node.js APIs are unavailable. This is not a security sandbox; code can still make network requests. Only run trusted code.
- Why did my console.log output not appear?
- Output streams live, including timers after the snippet returns. Stop, a new run or the 30-second execution limit outside input waits ends the worker. Output is capped at 500 rows.
- Can I edit other languages?
- The playground is for JavaScript, so the editor stays in JavaScript mode. The plain text area still holds whatever you paste, but the highlighting and the formatter are the JavaScript ones.
- Does it remember my code between visits?
- The editor starts from a small example each time. If you want to keep a snippet, use Copy before you leave, or paste it into your own notes.