Online JavaScript Compiler
Write, run and test JavaScript code online, right in your browser. This free online JavaScript compiler needs no installation or signup — just type your code and click Run.
JavaScript is the language of the web. Here it runs on Node.js, so you can practise core JavaScript — variables, functions, arrays, objects and async code — without a browser.
How to use the JavaScript compiler
- Write or paste your JavaScript code in the editor.
- If your program reads input, open the I/O tab and type it into the STDIN box (one value per line).
- Click Run — the output and any errors appear in the output panel.
Sample: read input in JavaScript
const lines = require('fs').readFileSync(0, 'utf8').trim().split('\n');
console.log(`Hello, ${lines[0]}!`);
Paste this into the editor, type your name in the STDIN box and click Run.
More JavaScript examples to try
Arrays: map, filter and reduce
The three array methods every JavaScript developer uses daily.
const prices = [120, 45, 300, 80];
const withTax = prices.map(p => p * 1.18);
const cheap = prices.filter(p => p < 100);
const total = prices.reduce((sum, p) => sum + p, 0);
console.log('With tax:', withTax);
console.log('Under 100:', cheap);
console.log('Total:', total);
Async / await
Simulates a slow task with a Promise and waits for it with await.
const wait = (ms) => new Promise(resolve => setTimeout(resolve, ms));
async function main() {
console.log('Starting...');
await wait(1000);
console.log('Done after 1 second');
}
main();
Common JavaScript errors and how to fix them
ReferenceError: x is not defined- The variable was never declared, or is used outside the block where
let/constcreated it. TypeError: Cannot read properties of undefined- You accessed a property on something that is
undefined— check the object exists first, or use optional chaining:obj?.prop. document is not defined- This compiler runs JavaScript on Node.js, which has no web page or
document. For DOM code, use the HTML editor instead. prompt is not defined- Node.js has no
prompt(). Read input from STDIN withrequire('fs').readFileSync(0, 'utf8'), as in the sample above.
Frequently asked questions
Is this online JavaScript compiler free?
Yes. It is completely free to use, with no signup required to write and run code.
Do I need to install anything?
No. It all works from your web browser, so there is nothing to download or set up — it works on Windows, macOS, Linux, Chromebooks and phones.
How do I give input to my JavaScript program?
Before clicking Run, type the input into the STDIN box under the I/O tab, one value per line. Your program reads it as standard input, just like typing in a terminal.
Is this good for learning JavaScript?
Yes. It is ideal for practising exercises, testing small programs and trying out ideas from tutorials, because you can run code instantly without configuring an environment.
Other online compilers
Python Compiler Java Compiler C Compiler C++ Compiler C# Compiler TypeScript Compiler SQL Compiler React.js Compiler HTML Compiler Go Compiler Rust Compiler R Compiler PHP Compiler Kotlin Compiler Swift Compiler Scala Compiler Dart Compiler Ruby Compiler Prolog Compiler Perl Compiler
Editor powered by OneCompiler.