JavaScript playground

Run JavaScript online

Write and run JavaScript online with Node.js. A free JavaScript compiler in your browser: see console.log output and errors, with nothing to sign up for.

Code main.js

// Welcome to the coding.kitty JavaScript playground.
// Press Run (or Ctrl+Enter) to see what this prints.

const cats = ["Miko", "Nola", "Baymax"];

cats.forEach((name, index) => {
  console.log(`${index + 1}. ${name} says meow`);
});

console.log(`That's ${cats.length} cats.`);

// Type something in the Input box, then remove the // from these two lines:
// const input = require("fs").readFileSync(0, "utf8");
// console.log(`You typed: ${input.trim()}`);
Output

Press Run to see what your code prints.

About this JavaScript playground

This is a JavaScript compiler you can use straight away. Write JavaScript in the editor, press Run, and the output appears next to it: everything you console.log, any error with its stack trace, and how long it took.

Your code runs on Node.js in an isolated sandbox on our servers, so it behaves like a script you run with node on your own machine. It is free, with nothing to install and no account needed.

What you can run

  • Node.js, running one file per run, saved as main.js.
  • Standard library only. Every built-in of the language is there (Math, JSON, Date, Map, Set, Promise and the rest), plus Node's own modules such as fs, path, util and crypto, loaded with require(). There is no package installer, and programs have no network access.
  • Limits: 10 seconds and 256 MB of memory per run. Output past 64 KB is cut off, code can be up to 64 KB and input up to 16 KB.
  • Fair use: 5 runs a minute and 50 a day without an account, 10 a minute when you are signed in.

Reading input

Open the Input box under the editor and type what your program should read. Node hands it to your program as standard input, which you can read all at once with fs. With the box empty, you read an empty string.

const input = require("fs").readFileSync(0, "utf8");

Frequently asked questions

Is this online JavaScript compiler free?

Yes. There is no sign-up and no limit on how much you can write. Signed-out visitors get a quick, usually invisible bot check when they press Run, and a fair-use cap of 5 runs a minute and 50 a day. Signing in raises it to 10 runs a minute.

Does my code run in the browser or on Node.js?

On Node.js, in a sandbox on our servers. That means console.log, require() and Node's built-in modules work, but browser-only things such as document, window and alert do not exist. For a web page with HTML and CSS, you want a front-end editor instead.

Can I use npm packages?

No. The playground runs the language and Node's built-in modules only: there is no npm install, and programs have no network access, so fetch() calls to other sites fail.

How do I read input in the JavaScript playground?

Type it in the Input box under the editor, then read it from standard input: require("fs").readFileSync(0, "utf8") returns everything in the box as one string, which you can split into lines.

Why did my program stop with a time-out?

Each run gets 10 seconds and 256 MB of memory. A program that goes past either is stopped. The usual cause is a loop that never ends, or a timer such as setInterval that keeps the program alive.

Is my code saved or shared?

Your code is kept in your own browser so it is still there next time, and nowhere else. When you press Run it is sent to our code runner, run once in a sandbox, and thrown away. We do not store it or show it to anyone.

Keep going

Also in the playground: Python, TypeScript, SQL, Bash, C, C++, Go, Rust, Java, C#, Ruby, PHP, Lua, R, Dart, Swift.