About the online JavaScript compiler
This page runs JavaScript directly in your browser. Write code in the editor, press Run, and anything you pass to console.log appears in the output console.
Your code runs in a background Web Worker, separate from the page itself, so a slow loop will not freeze the editor. It is a quick way to test logic without opening developer tools or creating an HTML file.
How to use it
- Write JavaScript in the editor.
- Press Run.
- Check the console for output from console.log, and for any error messages.
- Change the code and run it again.
Example: group items with reduce
Paste this into the editor to see how reduce can turn a list into a lookup object.
const people = [
{ name: "Ada", team: "core" },
{ name: "Linus", team: "kernel" },
{ name: "Grace", team: "core" },
];
// Group names by team
const byTeam = people.reduce((groups, person) => {
(groups[person.team] ??= []).push(person.name);
return groups;
}, {});
console.log(byTeam);What it is good for
- Trying array methods such as map, filter, and reduce
- Checking how closures, promises, or async functions behave
- Testing a function before pasting it into a project
- Practising interview-style problems
Frequently asked questions
Where does my JavaScript run?
In your own browser, inside a Web Worker. Nothing needs to be installed.
Can I use the DOM, document, or window here?
No. A Web Worker has no page to manipulate, so document and window are not available. To build something with HTML and CSS, use the HTML, CSS & JS editor instead.
Is JavaScript a compiled language?
JavaScript is delivered as source code and compiled just-in-time by the browser engine as it runs, so you never run a separate compile step yourself.
Is the JavaScript compiler free?
Yes. It is free and works without an account.