JavaScript Playground

A scratchpad for trying an idea in JavaScript, with a console that understands table, group, time and count.

JavaScript
Console
Runs locally in your browser

About the JavaScript Playground

This playground exists for the moment when you want to know what a snippet actually does before it goes anywhere near a project. Type or paste code on the left, and everything it prints appears on the right. A fresh sandboxed frame is created for every run and thrown away afterwards, so variables never leak from one attempt into the next and nothing you write can reach this page, its storage or the network.

The console shim goes beyond plain logging. console.table renders an aligned text table from an array of records, which makes a list of objects far easier to scan than a wall of braces. console.group and console.groupEnd indent whatever sits between them. console.time and console.timeEnd report elapsed milliseconds, and console.count tallies how often a line was reached. Maps, Sets, dates, regular expressions, functions and circular references all print as something readable instead of the useless object notation.

If the last statement produces a value it is shown after an arrow, so a one line expression needs no logging at all. Code that uses await at the top level is wrapped in an async function automatically. The time limit stops runaway loops: pick two, five or ten seconds depending on what you are trying, and the summary line at the end reports how many console lines were produced and how long the run took.

For a stripped down runner without the summary, use JavaScript Runner; when you want to check assertions rather than read output, open the JavaScript Tester.

How to use

  1. Write or paste JavaScript on the left. The Sample button loads a short statistics snippet.
  2. The code runs shortly after you stop typing, and the console output appears on the right.
  3. Raise the Time limit before running something heavy, or lower it while experimenting with loops.
  4. Use console.table for arrays of objects and console.group to indent related lines.
  5. Copy the console output or download it as a text file.

Common questions

Can my code reach the page around it?
No. It runs inside a sandboxed frame with no access to this document, to cookies or to storage, and the frame is destroyed after every run.
Does top level await work?
Yes. If the parser rejects a top level await, the code is rerun wrapped in an async function, so promises resolve before the run is reported as finished.
Why did my loop stop with a time limit message?
The run exceeded the limit set in the toolbar, which usually means a loop condition never becomes false. Fix the condition or raise the limit to ten seconds.
Can I fetch data from an API in here?
No. The sandbox has no network access, so build your input as a literal in the code instead.
Where does the value after the arrow come from?
It is the value of the last expression in your code, printed automatically so short experiments need no console call.