JavaScript playground
Online JavaScript compiler
Write JavaScript, press Run and see the console output. It runs in your browser with no install and no sign-up.
Ctrl/Cmd + Enter to run
Loading editor...
Output
Run your code to see its output here.How this JavaScript compiler works
- Runs in a Web Worker in your browser, so a long loop cannot freeze the page.
- Supports modern syntax, including top-level await, classes, generators and async functions.
- console.log, console.error and console.warn appear in the Output panel. Use input() to read from the Input box.
- There is no page or DOM: window, document and import statements are not available. A program is stopped after 10 seconds.
Your code is saved on this device as you type. Press Share to get a link that contains your code, and anyone who opens it sees the same program.
Also try: Python compiler, TypeScript compiler
Questions about the JavaScript compiler
Where does the code run?
In a Web Worker inside your browser, using your browser’s own JavaScript engine. Nothing is sent to a server.
Can I use the DOM, document or window?
No. The code runs in a worker, which has no page. This playground is for logic, algorithms and console output.
Can I use import or require?
Not yet. Programs run as a single script. Top-level await works.
How do I read input?
Call input(). It returns the next line from the Input box, or null when the lines run out.
What happens with an infinite loop?
The program is stopped after 10 seconds, or immediately when you press Stop. Your page keeps working either way.