HTML Viewer with a Sandboxed Preview – Free

This HTML viewer renders pasted markup in a sandboxed frame on the page. Inline CSS works, while scripts, forms and remote resources are stripped or blocked before anything is displayed.

How to use the HTML viewer tool

  1. Paste a fragment or a full document into the HTML box, or select Example to load a heading and a paragraph.
  2. Select Preview HTML to render the markup in the frame below the Result box.
  3. Compare the rendered frame with the source, which is echoed unchanged in the Result box.
  4. Edit the markup and select Preview HTML again. Any change to the input clears the previous preview.
  5. Select Copy if you want the source from the Result box on your clipboard.

How the HTML viewer isolates your markup

Rendering happens in three layers. First the page parses your HTML into an inert template and deletes elements that can run code or load other documents. Then it removes link targets that point away from the page. Last, it places what is left into an iframe that carries an empty sandbox attribute and its own Content Security Policy.

An empty sandbox attribute is the strictest setting in the HTML Standard: the frame gets a unique origin, cannot run scripts, cannot submit forms, cannot open popups and cannot navigate the surrounding page. The policy inside the frame is default-src 'none' with two exceptions, inline styles and images from data: URLs. Event handler attributes such as onclick are left in the markup but never fire, because script execution is off.

What is removed and what still renders

Use this list to predict how a page will look in the preview.

  • Removed together with their contents: script, iframe, frame, object, embed, form, link, meta and base elements, plus SVG animate, set and foreignObject.
  • Links keep their text, but the href is dropped unless it starts with #, so only same-page anchors remain.
  • Style elements and style attributes apply normally.
  • Images render only when the src is a data: URL. Remote images and CSS background images from a web address do not load.
  • External style sheets, web fonts, audio and video are blocked by the policy.

Worked example: before and after cleaning

The first line below is the input and the second is the markup handed to the frame. The script element is gone, the outbound link has lost its target, and the styled heading and the in-page link are untouched. The Result box still shows the first line, since it echoes your source.

<style>h1{color:teal}</style><h1>Release notes</h1><script>alert(1)</script><a href="https://example.com">Docs</a> <a href="#top">Top</a>

<style>h1{color:teal}</style><h1>Release notes</h1><a>Docs</a> <a href="#top">Top</a>

When a preview looks wrong

Most surprises come from pages that depend on something outside the pasted text. A page styled by a linked style sheet renders as unstyled HTML, since link elements are removed. A page built by JavaScript shows only its static shell.

To check layout, inline what the page needs: move CSS into a style element and convert small images to data URLs. Full documents are accepted, but the doctype and the html, head and body wrappers are discarded during parsing, so attributes set on the body tag are lost.

Frequently asked questions

Does the HTML viewer run JavaScript?

No. Script elements are deleted before rendering, and the preview frame is sandboxed without the allow-scripts permission, so inline event handlers do not execute either. Use it to inspect markup and CSS, not to test scripts.

Why are my images missing in the preview?

The frame's Content Security Policy allows images from data: URLs only. An img tag that points to an http or https address, or to a relative path, is blocked. Embed the image as a Base64 data URL to see it.

Is the HTML I paste sent to a server?

No. The markup is parsed and displayed by your browser on this page. The preview frame is also barred from loading remote files, because its policy blocks every network source.

Can I preview a complete page with head and body?

Yes, paste the whole document. The title and style elements from the head are kept, while meta and link elements are removed. The html, head and body tags themselves are dropped, so the content renders as a fragment.

Why does clicking a link in the preview do nothing?

Outbound links are disabled on purpose. The viewer strips the href from every anchor unless it begins with #, which keeps the preview from navigating away or opening an untrusted address.

Can I download the rendered page?

No file is produced. The Result box repeats the source you entered and has a Copy button, with no Download link.

Related tools