HTML/CSS/JS Live Preview

Write HTML, CSS and JavaScript in three editors and see the result live in a sandboxed preview.

The HTML/CSS/JS Live Preview lets you write a web page in three separate editors, one for HTML, one for CSS and one for JavaScript, and see the result update as you type. The page runs inside a sandboxed frame, and a console panel shows what your JavaScript prints. It is meant for quick experiments, demos, bug reproductions and learning.

What is a live preview sandbox?

A web page is built from three layers: HTML describes the content and structure, CSS describes how it looks, and JavaScript describes how it behaves. Keeping them in separate editors makes each part easy to read and edit. To show the result, this tool combines your three parts into one complete page and loads it into an iframe, a page embedded inside this page. The iframe has the sandbox attribute set to allow scripts only. Without the allow-same-origin permission, the browser gives the frame an opaque origin of its own, so your code cannot read this site's cookies, local storage or data. A Content-Security-Policy tag inside the page also stops it from loading anything from the internet unless you allow it. Your JavaScript really does run, so this is isolation for experiments, not a guarantee that any code is harmless.

How to use HTML/CSS/JS Live Preview

  1. Choose a starting point Pick a Sample page (Counter button or Profile card) to fill the three editors, or press Clear all and start empty.
  2. Write the three parts Put content in the HTML editor, styles in the CSS editor and behaviour in the JavaScript editor. Each editor has its own Copy and Clear buttons.
  3. Watch the preview The page appears in the Preview box and updates as you type. Choose a Preview width to see how it looks at desktop, tablet or phone size.
  4. Read the console Messages from console.log and errors from your script appear under Console. An error shows the line of your JavaScript where it happened.
  5. Save or share Use Copy on an editor to copy one part, or Download .html to save the whole page. Reset to sample restores the selected sample.

Frequently asked questions

Is my code sent to a server?

No. The three editors are combined in your browser and shown in a frame on this page, and nothing is uploaded. If you tick Allow external resources and your page asks for an https image, script or other file, your browser fetches it from that site, as it would for any web page.

Can my code access my cookies or other tabs of this site?

No. The frame is sandboxed with scripts allowed and nothing else, so it gets its own isolated origin without access to this site's cookies, storage or data. Treat this as strong isolation for experiments, not as permission to run code you do not trust.

Can I use a library from a CDN?

Yes. Tick Allow external resources (https) and add a script tag with an https address in the HTML editor. With the box unticked the script is blocked.

What happens if my code has an endless loop?

The preview frame, and possibly your browser tab, will stop responding, because this tool has no time limit on your JavaScript. Close or reload the page to recover, and be careful with while loops that never end.

Is my work saved?

No. The editors are held in the page only, so a reload loses them. Use Copy on each editor or Download .html to keep your work.

Do the width buttons emulate a phone?

They only change the width of the preview frame to 1024, 768 or 375 pixels. Media queries in your CSS react to that width, but touch events, device pixel ratio and mobile browser behaviour are not emulated.