Skip to content
Codoryn Search tools

HTML Viewer & Live Preview

Paste HTML and preview it instantly in a sandboxed frame that blocks scripts and external resource loads. Your markup is checked and rendered in your browser.

How the preview is isolated

Pasted HTML is treated as untrusted. Four independent measures apply, and each one alone would stop a script from running:

  1. The markup is sanitised against a strict allowlist before it is used at all.
  2. It is rendered inside an <iframe> using srcdoc, so the document never appears in the address bar or in history.
  3. That frame carries sandbox="" — every restriction applied, no capability granted back. It cannot run scripts, submit forms, open windows, navigate this page, or read anything belonging to Codoryn.
  4. A Content Security Policy of default-src 'none' is injected as the first thing in the document, so no image, stylesheet, font or connection can reach the network.

What is removed

Scripts, event-handler attributes such as onclick, javascript: URLs, iframes, objects and embeds, forms, <base>, <meta http-equiv> including refresh, external stylesheets, and any src that is not a data: URI declaring a supported raster image type (PNG, JPEG, GIF, WebP, AVIF, BMP or ICO).

SVG and MathML are removed entirely in v1. Both carry their own scripting surface and have a long history of getting past sanitisers. A partial allowlist for them is a research project rather than a feature, so this version does not attempt one.

What is kept

Structure and styling, because that is the point of a viewer. Inline <style> blocks and style attributes are applied, and class and id survive.

Within that CSS, every @import and every url() is removed — including url(data:…), which is local and would be harmless. Telling a safe URL from an unsafe one inside CSS means parsing a value grammar full of escapes, comments and quoting, where a single miss is a request you did not make; removing the whole class is something that can actually be proven, so that is what this version does. Everything else in the rule is kept.

Images embedded as data: URIs render normally, provided they declare one of the supported raster types. data:image/svg+xml is refused along with the rest of SVG.

What this tool is not

It is not a validator. Browsers accept malformed HTML and so does this preview; nothing here checks your markup against a standard or tells you it is conformant.

It is not a playground. Because scripts never run and nothing is fetched, a page that depends on JavaScript or on remote assets will not behave here as it does on the web. That is deliberate, and it means this is not a substitute for a browser when you are testing behaviour rather than markup.

Frequently asked questions

Why doesn't my JavaScript run?

Because running pasted JavaScript is the thing this tool exists to avoid. The sandbox withholds allow-scripts and the policy sets script-src 'none', so there is no configuration in which it executes.

Why are my images missing?

Remote images would tell that server you had opened the document. Their src is removed and the alt text is kept. Images embedded as data: URIs are local, so they display — as long as they are a supported raster type. An SVG data URI is refused, because SVG is a document with its own scripting surface rather than a picture. A CSS background-image is removed even when it uses a data: URI; use an <img> for embedded images.

Is my HTML uploaded?

No. It is checked in a Web Worker and rendered in your browser in a sandboxed frame that blocks scripts and external resource loads, and this tool does not send your input over the network.

How large a document can I preview?

Up to 128 KB, with live rendering up to 64 KB. Raw HTML is far denser in elements than the same weight of prose, and each render builds a whole document and lays it out, so the limit is set where the page stays responsive rather than where it merely finishes.