HTML, CSS & JavaScript Playground

A lightweight online code editor: type HTML, CSS and JavaScript, watch the preview update, and read console output and errors below it.

Loading tool…

About the HTML/CSS/JS Playground

The preview is an <iframe sandbox="allow-scripts"> loaded through srcdoc. Your script runs in a unique opaque origin, so it cannot read this page, its cookies or local storage. Pop-ups, alerts, form submission and top-level navigation are blocked by the sandbox, which keeps experiments harmless.

console.log, info, warn, error and debug are forwarded to the Console panel with postMessage, together with uncaught errors and unhandled promise rejections. Objects are shown as JSON and error line numbers refer to the JavaScript editor. Your browser's DevTools still show the originals if you need to inspect live objects.

With auto-run on, the preview reloads 0.7 seconds after you stop typing. Code is kept in this browser's local storage between visits and never uploaded. Download produces a single self-contained HTML file with your CSS in a <style> tag and JavaScript at the end of the body, ready to open locally or host anywhere. It is meant for quick experiments, bug reproductions and teaching snippets rather than full projects.

How to use it

  1. Edit the HTML, CSS and JavaScript panes; Tab inserts two spaces.
  2. Watch the preview update, or turn off Auto-run and press Run.
  3. Read logs and errors in the Console panel.
  4. Switch layout if you want wider editors.
  5. Download the result as a single HTML file or copy it.

Frequently asked questions

Can I use npm packages or ES modules?
You can load libraries from a CDN with a <script src> tag in the HTML pane, or import them from an ESM CDN inside <script type="module">. There is no bundler.
Why does alert() not work?
The sandbox does not include allow-modals, so alert, confirm and prompt are blocked. Use console.log instead.
Is my code saved?
It is saved in your browser's local storage on this device only. Use Download .html to keep a copy or share it.
Why can't my script access localStorage or cookies?
The preview runs in an opaque origin without allow-same-origin, so storage APIs throw a SecurityError there.

Related tools