DevTools Logo

JavaScript Playground

About this tool

The JavaScript Playground is a full-width snippet lab with the editor above its output. Code executes in a Web Worker so experiments cannot freeze the tab; Stop and timeout terminate the worker.

Use it for algorithms, console experiments and reproducing a one-file bug. For a full page with HTML and CSS, open the HTML Editor in the same Code Playgrounds category.

How to use this tool

  1. Edit

    Type JavaScript or load an example.

  2. Run

    Output captures console.log, warnings and thrown errors.

  3. Stop or reset

    Stop aborts a hung run; Reset restores the default snippet.

Use cases

Quick experiments

Try a reduce, a regex or a Date snippet without opening DevTools on another site.

Teaching

Share the idea of Run + console without installing Node.

Frequently asked questions

Where does my JavaScript run?

Inside a Web Worker. The parent tab can terminate the worker on Stop or timeout, so an infinite loop cannot freeze the page. Console.log is captured into the Output panel.

Is my code uploaded?

No. Source stays in this tab and in localStorage on your device.

Can I use the DOM?

No. Workers have no document. For HTML/CSS/JS together use the HTML Editor, which live-previews a full page.

What happens on an infinite loop?

Run stops after a few seconds and reports a timeout so the tab stays usable.