About this JavaScript compiler
This free online JavaScript compiler runs your code right in the browser and shows everything you log with console.log. It is meant for quick experiments: testing a function, checking how an array method behaves, or practising for an interview.
Your code runs in an isolated Web Worker, so a mistake like an endless loop can be stopped without freezing the page. Modern syntax such as async/await, classes and top-level await works out of the box.
How to use it
- Write or paste your JavaScript in the editor.
- Press Run (or Ctrl + Enter).
- Anything passed to console.log, console.info, console.warn or console.error appears in the output panel.
- If your code uses prompt(), type the answers in the Input box first, one per line.
Features
- Modern JavaScript, including async/await and top-level await
- console.log, console.warn and console.error shown with colours
- prompt() reads values from the Input box
- Stop button for runaway loops
- Dark and light themes, automatic saving in your browser, download as .js
Good to know
- Code runs in a Web Worker, so browser-page objects such as document and window are not available. Use the HTML/CSS/JS editor for those.
- Programs that run for more than about 15 seconds are stopped.
- Node.js modules such as fs or require() are not available.
Frequently asked questions
Is this a Node.js compiler?
No. It runs your code with the JavaScript engine of your own browser. That means everything in standard JavaScript works, but Node-specific modules like fs and require() do not.
Can I use document or window?
Not here. Code is run in a Web Worker for safety, and workers have no page. If you want to work with HTML elements, use the online HTML/CSS/JS editor instead.
Does it support async/await?
Yes, and you can use await at the top level of your script without wrapping it in a function.
How do I read user input?
Use prompt('message'). It returns the next line from the Input box, or null if you have not typed enough lines.
What happens with an infinite loop?
Press Stop to end the program. It is also stopped automatically after about 15 seconds.
See it run step by step
Want to understand how your program works? Try the JavaScript visualizer, which runs your code one line at a time and shows every variable.