JavaScript Playground
Run JavaScript in your browser and see console output, results and errors, with several files, a time limit and a zip download.
Press Run to see the output here.
Shortcuts: Ctrl+Enter run · / search (use ⌘ on Mac)
Free Online JavaScript Playground and Console
Run JavaScript and see the output. Write code on the left, press Run, and the console on the right shows what your code prints, the value of its last line and any error with its file and line. It runs in your browser, so nothing you write is uploaded. Use it to check a snippet, try a new array method or test a small function without opening an editor or a terminal.
How to use the JavaScript playground
- Type or paste code in main.js, or press Load the sample in the ⋯ menu to start from an example.
- Press Run (or Ctrl+Enter). Messages from
console.log,console.tableand friends appear on the right. - For more than one file, press +, name it
utils.js, and useimportandexportto share code between files. - Choose a time limit under the editor. If a run gets stuck, press Stop.
- Open the ⋯ menu and choose Download all files (.zip) to keep your project in one folder.
What runs and what does not
The code runs in a background worker, so it has no page to draw on: there is no document or window. To build a web page, use the HTML/CSS/JS Playground. Standard JavaScript, promises, timers, JSON and top-level await all work. Network calls are blocked unless you switch on the internet option. To tidy or shrink finished code, try the JavaScript Beautifier and the JavaScript Minifier.
Worked example
The sample project has two files. main.js imports a helper from utils.js, prints an average and a table, waits a moment, then finishes:
import { average, wait } from './utils.js';
const scores = [72, 85, 90, 64];
console.log('Average score:', average(scores));
console.table(scores.map((score, i) => ({ student: 'S' + (i + 1), score })));
await wait(300);
console.log('Done after a short pause');
Result in the console: Average score: 77.75, a small table of four students, then Done after a short pause.
Common mistakes
- Looking for
documentorwindow: this playground has no page. Use the HTML/CSS/JS Playground for that. - Importing a package such as
lodashbefore adding it: press Add packages first. - Using
awaitat the top level of a file you import (not the main file): put it inside an async function instead. - Leaving a
setIntervalrunning: the run stays open until you press Stop or the time limit ends it.