Skip to content

JavaScript Online Compiler

Run JavaScript instantly, with console output and Node-style input.

main.js
Open in K-Programmer ↗ Free course Ctrl+Enter runs · Tab indents · Esc then Tab leaves the editor
Output
 

Runs in your browser in a separate worker. Nothing is uploaded.

Report a problem

Don't include personal or sensitive information.

What happened, and what did you expect? (10–2000 characters) 0 / 2000

Your browser and system, screen size and recent error messages on this page. Never what you typed or your files. Privacy

What is sent
 

Type JavaScript and see the result immediately. Your code runs in your own browser's JavaScript engine (V8, SpiderMonkey or JavaScriptCore) inside a separate worker, so it is fast, works offline once the page has loaded, and cannot touch the page or your data. Modern syntax all works: let/const, arrow functions, classes with private fields, destructuring, async/await.

Programs written for Node.js and online judges work unchanged: read the Input box with require("fs").readFileSync(0, "utf8"), the readline module, or prompt(). console.log prints objects and arrays readably, and console.table draws tables.

How to use the JavaScript Online Compiler tool

  1. Write JavaScript in the editor or pick a sample.
  2. Type the program's input in the Input box if it reads any.
  3. Click Run or press Ctrl+Enter; output appears instantly.
  4. Use Stop for an endless loop, then fix the code and run again.
  5. Share the program with Share code or open it in K-Programmer.

Why use ToolOrca JavaScript Online Compiler

  • Instant runs in your browser, no server round trip and no limits
  • Node-style input: fs.readFileSync(0), readline, prompt()
  • Readable console.log of objects, arrays, Maps and Sets; console.table
  • Stop button, error messages with line numbers
  • ES2023 syntax, async/await, timers
  • Syntax highlighting, line numbers, autosave and share links

Reading input like Node.js

The easiest way: const lines = require("fs").readFileSync(0, "utf8").trim().split("\n"); gives every line of the Input box as an array. With readline, rl.on("line", ...) is called once per line and rl.on("close", ...) at the end, as on HackerRank or Codeforces.

prompt() and readline() return the next line (or null when the input is used up), which is handy for quick exercises.

What runs and what does not

The code runs in a Web Worker: there is no document or window, so use the HTML compiler for web pages. Only fs (reading standard input), readline and process can be required; npm packages and file access are not available.

Because it runs on your device, there is no time limit; an endless loop keeps going until you press Stop. Timers (setTimeout, setInterval) work, and the run ends when the last timer has fired.

Practise JavaScript

The samples show input, loops, arrays and objects with map/filter/reduce, functions and classes, and recursive binary search.

For JavaScript and web lessons with quizzes, continue in K-Programmer.

Frequently asked questions

Does this run Node.js?

It runs in your browser's JavaScript engine, with Node-style helpers for input (fs.readFileSync(0), readline, process.stdout.write). Most judge-style Node programs run unchanged.

How do I read input?

Type it in the Input box, then use require("fs").readFileSync(0, "utf8"), the readline module or prompt().

Can I use the DOM or alert()?

Not here: this page runs code in a worker without a page. Use the HTML, CSS and JS compiler for anything that touches the page.

How do I share my code?

Click Share code. The link that is copied contains your code and input, compressed, after the # sign, so nothing is stored on a server and the link works as long as you keep it.

What is "Open in K-Programmer"?

K-Programmer is a free platform for learning to code, with lessons, quizzes, contests and the same online compiler. The button copies your code and opens K-Programmer, where you choose the language, paste the code and keep working (sign in to save programs).