Swelıty
Tools for everyone

Free Online JavaScript Playground

Run JavaScript online with an HTML page. See the live preview and the console output side by side.

Press Run, or Ctrl or Cmd + Enter, to run your code. The page shows in Preview and everything you log shows in Console. Use Stop if a script never ends.

Preview

Console

Output appears here. Press Run, then try console.log("Hello")

How to use

  1. Write JavaScript in the JavaScript tab, and any markup it needs in the HTML tab.

  2. Press Run, or Ctrl or Cmd + Enter, to run your code. Or turn on Auto-run to run it whenever you stop typing.

  3. See the page in Preview, and read what your code logs in the Console. Click an object or array to expand it. Errors are shown in red, with their line number where possible.

  4. Use Stop to end code that is still running, and the clear icon in the editor to start from scratch.

  5. Open the full screen editor for more room, and use the A buttons to resize the text.

  6. Press Format to tidy the tab you are editing, or untick Wrap long lines to scroll sideways instead.

Why use this tool

  • Preview and console together

    The page and the console output are always shown side by side, so you can see what your code does and what it logs.

  • Expandable console

    Everything you pass to console.log, info, warn, error and debug appears in the Console panel. Click an object or array to expand it and look inside, or use Expand all and Collapse all.

  • Top-level await

    Use await directly, without wrapping your code in a function.

  • Isolated preview

    Your code runs in an isolated frame, so it cannot reach this site or your other tabs.

  • One-click formatting

    Tidy the indentation and spacing of the tab you are editing with one click or Shift + Alt + F.

  • Comfortable editor

    Resize the text, switch line wrapping on or off, or go full screen with the editor and preview side by side.

About this tool

Run JavaScript in your browser and see the result straight away. This online JavaScript editor runs your code alongside an HTML tab in a sandboxed preview, with the page on one side and everything you log with console.log in a console on the other. Try a function, an array method or an algorithm, or test code that changes the page or reacts to clicks.

This JavaScript playground runs your code in the browser and shows the result straight away. The page you build with an HTML tab appears on one side, and everything you log with console.log appears in an expandable console on the other. Top-level await works, and the preview is isolated from this site.

Try a function, an array method or an algorithm, or test code that changes the page or reacts to clicks. For React use the React Playground, and for Node-style code use the Node Playground.

Frequently asked questions

Press Stop to end it. The preview runs separately from the rest of the page, so you can still use the page while it runs. If it does not respond, close and reopen the tab. Your last code is kept in this browser.

Not unless you turn on Auto-run. It is off by default, so your code only runs when you press Run, or Ctrl or Cmd + Enter. With Auto-run on, your code runs as soon as you turn it on if it is not already showing, and then about a second after you stop typing. It never runs by itself when the page loads. Turn it off if your code makes network requests, shows popups or loops.

Requests to https addresses are allowed, but the other site must allow them.

You can load a script from an https address with a script tag in the HTML tab. Package imports and build tools are not supported.

No. This playground runs plain JavaScript.

Your code runs as a module, which keeps its variables private to your script and allows top-level await.

Yes. Press Format, or Shift + Alt + F while you are typing, to tidy the tab you are editing. If the code has a syntax error it is left unchanged and the problem is shown under the editor.

Yes. Untick Wrap long lines under the editor and it scrolls sideways instead. Your choice is remembered on this device.

Write your code and press Run. The result shows in the preview, and console.log output appears in the console.

Yes. Everything you log appears in a console beside the preview, which you can expand.