JavaScript Playground
Try JavaScript instantly: write code, press Run and see console output, errors and timing, safely isolated from this page, with top-level await and a page area for DOM tests.
Runs in your browser. Your files never leave your device. See how to check
…
How to do it
- 1Write code
Type or paste JavaScript.
- 2Pick an example
Optional, from the examples list.
- 3Turn on the page area
For DOM experiments.
- 4Run
Press Run.
- 5Read the console
Check output, errors and timing.
- 6Save
Keep the snippet with Save settings.
About this tool
Sometimes you just want to check what Array.prototype.toSorted returns, test a regular expression, try a date calculation or see how a small function behaves, without creating a project or opening the browser console on a random page. This playground runs JavaScript in your browser and shows the output. Code runs as a module, so top-level await works and you can fetch public APIs. console.log, info, warn, error and table are captured and shown with their level, objects are printed as formatted JSON, and uncaught errors and rejected promises are reported. The total running time is measured. Turn on the page area to experiment with the DOM: create elements, style them and see the result. The code runs inside a sandboxed iframe with a separate origin, so it cannot read this page, your cookies or your storage, which makes it safe to paste code you want to try.
What you can do
- Modern JavaScript: modules, top-level await, optional chaining, Object.groupBy, structuredClone and everything your browser supports. - fetch() calls to public APIs that allow cross-origin requests (CORS). - DOM experiments in the page area. - Timing: the run time from start to the end of the module.
Console
Output from console.log, info, warn, error, debug and table is shown in order, with warnings and errors in colour. Objects and arrays are printed as JSON. Errors show their message and, where available, the line.
Safety
The sandbox attribute allows scripts but not same-origin access, so the code runs in an opaque origin: no access to this site's cookies, localStorage or page. Each run starts with a fresh frame. Infinite loops freeze only the frame; reload the page if that happens.
Saving snippets
Use Save settings to keep the current code on this device under a name, and load it again from the examples and saved settings list. The snippet can also be downloaded as a .js file.
Examples
The examples cover array methods, async and await, fetching JSON from a public API and drawing on the page.
Learning with it
The playground is handy for trying examples from documentation or tutorials line by line: change a value, run again and watch the output change. Errors point to the line, so mistakes are quick to find.
Limits
There is no Node.js: require, fs and process are not available. npm packages cannot be installed, although ES modules can be imported from CDNs that allow it. Performance timings in a browser vary from run to run. This is a scratchpad for learning and testing, not a production environment.
Worked example
Running const counts = Object.groupBy(words, (w) => w.length) on the words of "the quick brown fox jumps over the lazy dog" prints groups for word lengths 3, 4 and 5, then a table, a yellow warning and the TypeError from null.boom, in about a millisecond.
Quick facts
- Category: Developer & Data
- Works in your browser, no sign-up, no upload.
- Your input stays on your device.
- Available in English.
- Content last reviewed:
- Official source: ECMAScript language specification and HTML iframe sandbox attribute
Frequently asked questions
Is it safe to run code from the internet?
It runs in a sandboxed frame without access to this page or your cookies, but still only run code you understand.
Does top-level await work?
Yes. Code runs as a module.
Can I use npm packages?
Not installed packages; ES modules from CDNs that allow cross-origin imports work.
Can I save my code?
Yes, with Save settings on this device, or download it as a .js file.
Is my code sent anywhere?
No. It runs in your browser; only fetch calls you write go to the network.
Is Node.js available?
No. Browser APIs only.
