Skip to main content

HTML Viewer & Playground

Build and preview HTML, CSS, and JavaScript, then export a single file or project ZIP

Up to 65,536 characters per editor. Drafts reset when you reload.

Preview

Preview code runs in an isolated sandbox and cannot read this app’s page, cookies, or local storage. JavaScript is off by default, but HTML and CSS can still request remote resources such as images, stylesheets, and fonts. When enabled, JavaScript can also send data to external services. Turning JavaScript off reloads the preview and stops its current scripts. Exports remove executable markup while JavaScript is off. Requests go directly to the domains named in your code, so do not include sensitive data and only run code you trust. Your HTML, CSS, JavaScript, and script setting stay in this tab and reset when you reload.

Was this HTML Viewer & Playground helpful?

Help us keep tools reliable, fast, and bug-free.

What you can do with HTML Viewer & Playground

  • View html output
  • Run html and css
  • Preview web page
  • Export html project

How this developer utility works

Write HTML, CSS, and JavaScript in three editors, see the result rendered live in a sandboxed frame, and export a single HTML file or a ready-to-run project ZIP.

Example input

HTML: <h1>Hi</h1>, CSS: h1 { color: rebeccapurple }, JavaScript: document.title = 'Hi'

Example output

A rendered purple heading with executable markup inactive; preview and HTML exports enable JavaScript only when Allow JavaScript is checked

Practical workflow

  1. Edit the HTML, CSS, and JavaScript tabs — a starter card with a working button is loaded for you.
  2. Keep Live preview on to render as you type, or turn it off and press Run when you are ready.
  3. JavaScript starts off. Enable Allow JavaScript only for code you trust; turning it off reloads the preview immediately. Use Focus preview or Fullscreen to inspect the page.
  4. Export a standalone index.html, download markup.html / styles.css / script.js individually, or grab html-playground-project.zip with a README. Standalone and ZIP HTML exports remove executable markup while JavaScript is off; enabling it preserves and loads the code.

Common use cases

  • Prototype a component or landing-page section and hand the exported HTML to a teammate.
  • Test a snippet from a tutorial or Stack Overflow answer without setting up a local project.
  • Preview an HTML email or a fragment of generated markup before pasting it into a CMS.

Important notes and limitations

  • The preview uses an iframe without same-origin permission. Scripts cannot read this page, its cookies, or its local storage. JavaScript starts disabled, but HTML and CSS can still request remote images, stylesheets, and fonts; enabled scripts can also send data directly to external services. Do not include sensitive data and enable scripts only for code you trust.
  • No external libraries are injected. If your snippet needs a CDN script, add the <script> tag yourself in the HTML tab.
  • Each HTML, CSS, and JavaScript editor is capped at 65,536 characters to bound preview work. The three sources and script toggle stay in tab memory only and reset on reload. Previously saved local drafts are removed when the tool opens. With JavaScript off, standalone and ZIP HTML exports strip scripts, inline event handlers, active embeds, and dangerous script URLs; the ZIP still contains the JavaScript source file.

Local HTML preview servers & headless renderers

Serve HTML directory locally with live reload

npx -y serve ./public -p 3000

Spins up a lightweight HTTP static file server to test HTML, CSS, and asset loading locally.

Render HTML to screenshot with Playwright CLI

npx playwright screenshot --viewport-size=1280,720 index.html preview.png

Uses headless Chromium to render the HTML markup and capture a pixel-perfect PNG screenshot.

Iframe sandbox & asset loading troubleshooting

Blocked script execution in iframe because the frame's sandbox attribute is set

Cause: Preview iframe security policy restricts dangerous JavaScript execution ('sandbox="allow-scripts"' missing).

Solution: Ensure preview container enables safe script execution while preventing top-level navigation ('allow-same-origin allow-scripts').

Mixed Content: The page at 'https://...' was loaded over HTTPS, but requested an insecure resource

Cause: HTML code contains HTTP ('http://') images, styles, or scripts loaded inside an HTTPS preview origin.

Solution: Upgrade all asset URLs to protocol-relative ('//cdn.example.com') or secure HTTPS endpoints.

Continue your workflow

  • Code Formatter — beautify the HTML, CSS, or JavaScript before exporting.
  • HTML Entities Encoder — escape text you want to display literally inside the markup.
  • CSS to Tailwind — Convert custom HTML and CSS styles into utility Tailwind CSS classes.
  • OG Image Extractor — Extract and inspect OpenGraph social media preview images from web pages.

Frequently asked questions

Can I run JavaScript in the preview?

Yes, after you check Allow JavaScript. Execution is off by default. Scripts run in an iframe without same-origin access, so they cannot read this page, its cookies, or local storage, but can still send data to external services. Run only code you trust.

How do I get my work out of the playground?

Export a single index.html, download the three source files separately, or download the ZIP project. With Allow JavaScript off, HTML exports remove executable markup and do not load script.js; when enabled, the exported page preserves pasted executable markup and loads script.js. The ZIP contains script.js as source either way.

What if I paste a full document with <html> and <head> tags?

The tool detects it and injects your CSS into the existing head and your JavaScript before </body>, instead of wrapping the markup in its own template.

Are my drafts saved after I reload?

No. HTML, CSS, JavaScript, and the script setting stay in memory only and reset on reload. Each editor accepts up to 65,536 characters. Copy or export anything you want to keep before leaving the page.

Can the preview make network requests?

Yes. HTML and CSS can request remote images, stylesheets, and fonts even while JavaScript is disabled. If you enable JavaScript, code can also send data to external services. Requests go directly from your browser to the domains in the preview code, so do not include sensitive data.

Focused guides for this tool