JavaScript
Online JavaScript Editor
The editor above is CodeMirror set up for JavaScript: it highlights .js, .mjs and .json files, closes brackets and quotes as you type, and Ctrl+Enter (⌘+Enter on a Mac) runs the open file with Node.js 24. Below is what it does, with the keys as the app has them.
Try it aboveHow JavaScript runs here
- Versions
- Node.js 22, 24 (default), 26
- Run
node main.js- Limits per run
- 256 MB memory, 15 s of CPU time on half a core, 2 MB of output
- Time
- Up to 10 minutes a run (30 on a paid plan); waits 2 minutes for input (5 on a paid plan)
- Sandbox
- Each run gets its own Linux sandbox with no network access. Text files your program writes next to your code open as new tabs.
Keys for editing JavaScript
Ctrl on Windows and Linux is ⌘ on a Mac:
- Ctrl+/ comments or uncomments the selected lines with //.
- Ctrl+D selects the next occurrence of the word at the cursor: press it until every use of a const is selected, then type the new name once. Alt+drag puts a cursor on each line of a column, handy for editing the keys of an object literal.
- Alt+↑ and Alt+↓ move the line or selection, say a function call above the line that needs its result; Shift+Alt+↑ and Shift+Alt+↓ copy it.
- Ctrl+Shift+[ folds the function, class or object literal at the cursor, and Ctrl+Shift+] unfolds it (⌘+Alt+[ on a Mac).
- Tab and Shift+Tab indent or outdent the selection, and Ctrl+Shift+K deletes the line.
- Ctrl+F finds and replaces, Ctrl+G jumps to the next match, and Ctrl+Alt+G goes to a line number.
- Ctrl+Enter runs, Ctrl+C in the console stops a program stuck in a loop or a setInterval, and Ctrl+, opens settings.
Settings → Keyboard shortcuts lists them all.
Errors point back to the code
The editor doesn’t lint JavaScript as you type, so a misspelled property shows up when you run:
const scores = [72, 95, 88]; console.log(scores.lenght.toFixed(1));
/workspace/main.js:2
console.log(scores.lenght.toFixed(1));
^
TypeError: Cannot read properties of undefined (reading 'toFixed')
at Object.<anonymous> (/workspace/main.js:2:27)Node shows the line with a caret under the spot, then the stack trace, which goes on into Node’s own internals. main.js:2:27 is a link: click it to jump to line 2.
Settings that matter for JavaScript
- Tab size: 4 spaces by default. Set it to 2 under Settings → Editor if that’s the style your code uses.
- Font ligatures draw => and != as single glyphs in fonts that have them, such as JetBrains Mono.
- Word wrap keeps long template literals and chained calls on screen without scrolling sideways.
- Key bindings: Standard, Vim or Emacs.
- Suggestions while typing offers words and keywords from the file, so a long function name takes a few letters and Enter. AI code completions show as gray text that Tab accepts.
- Layout puts the console beside the code or below it, and Theme follows your computer or uses VS Code’s Light+ or Dark+ colors.
Files in the JavaScript playground
- The + after the tabs adds untitled.js; rename it with F2 to utils.js, utils.mjs or data.json.
- A JSON file loads with require('./data.json') in CommonJS code, or with JSON.parse(fs.readFileSync('data.json', 'utf8')).
- Run starts the open tab unless Entry file in run settings names one.
- Upload text files up to 3 MB in all, download everything as javascript-playground.zip, or Share a link (up to 128 KB) that opens a copy anyone can run and change.
Questions
Does the editor check JavaScript for errors as I type?
No. Problems show when you run: Node names the file, line and column, and the link takes you there.
How do I indent with 2 spaces?
Settings → Editor → Tab size, then pick 2. Indent with stays on Spaces unless you switch it to Tabs.
How do I turn on Vim keys?
Settings → Editor → Key bindings → Vim. Esc enters normal mode and i goes back to inserting.
Can I run HTML and CSS here?
No. Code runs on Node.js and output goes to the console, so there’s no page to render HTML or CSS.
Can I write TypeScript?
TypeScript has its own playground, where main.ts compiles with tsc and runs on Node.js. See the online TypeScript compiler.