JavaScript Playground

Run a snippet and see its console output, return value and timing. Top-level await and return work, so you can try an API call or a quick algorithm. Press Ctrl/Cmd + Enter to run.

Output

The snippet runs in this page rather than a sandbox, so it can read and change the page. Only run code you trust, the same rule as a browser console.

About this tool

A small console for trying JavaScript without leaving the page. Write a snippet, press Run, and see everything it logs, the value it returns and how long it took. Top-level await is supported, so you can experiment with promises and fetch as well as plain expressions.

Questions

Can I use top-level await?
Yes. The snippet is wrapped in an async function, so await works at the top level and return gives back a value. That also means you do not need to wrap everything in an async IIFE yourself.
Is the code sandboxed?
No. It runs in the page with the page's own privileges, exactly like the browser's developer console. That keeps it simple and lets it touch real APIs, but it also means you should only run code you trust.
Why did my console.log output not appear?
Only output produced while the snippet runs is captured, and the snippet has to finish for the run to end. If it throws, the error is shown instead and anything logged before the throw is still listed.
Does it remember my code between visits?
The editor starts from a small example each time. If you want to keep a snippet, use Copy code before you leave, or paste it into your own notes.