Developer tools

JavaScript Playground

JavaScript Playground

Run JavaScript in your browser and see console output and errors instantly.

About this tool

About JavaScript Playground

Run a snippet of JavaScript without opening a project or the browser's developer tools. The playground opens on the JS tab with an example that uses arrays, async code and console.table, and the console panel under the preview shows everything your code prints: console.log, info, warn, error and table, with repeated lines grouped and objects, arrays, maps, sets and errors formatted readably. Uncaught exceptions and rejected promises appear with the line number they came from, which makes it handy for checking how a method behaves, testing a regular expression, debugging an algorithm or teaching the basics. Modern syntax runs as-is because the code executes in your own browser, inside a sandboxed iframe that can't access this site's data. Use the HTML tab if your script needs elements to work with. Turn off Auto-run to execute only when you press Run or Ctrl/Cmd + Enter. Your code stays in this browser and is never uploaded.

Built and maintained by Abhi JainUpdated

How to Run JavaScript Online

  1. 1

    Write JavaScript

    Type in the JS tab, or click Sample for a working example.

  2. 2

    Run it

    With Auto-run on, it runs as you type. Otherwise press Run or Ctrl/Cmd + Enter.

  3. 3

    Read the console

    Output and errors appear in the Console panel. Click Clear to empty it before the next run.

JavaScript Playground: questions and answers

Which JavaScript version is supported?

Whatever your browser supports, which for any current browser includes modern syntax such as async/await, optional chaining, classes, private fields and recent array methods.

Can I use import or npm packages?

There is no bundler or npm. You can load a library from a CDN with a <script src> tag in the HTML tab, or use a dynamic import() of an ES module URL.

Can I run Node.js code here?

No. The code runs in a browser, so Node APIs such as fs, process and require are not available. Browser APIs such as fetch, setTimeout and the DOM are.

Is it safe to run code I found online?

The code runs in a sandboxed iframe with its own origin, so it can't read this site's cookies or storage. It can still use the network like any web page, so don't run code you don't understand with secrets in it.

More HTML, CSS & JS Playground presets