HTML Viewer & Preview
: Paste HTML or open an .html file and see it rendered in a sandboxed live previewHTML Viewer & Preview
See what a piece of HTML looks like when a browser draws it, next to the source, without letting it do anything. Paste markup from an email template, a CMS export or a chatbot answer, or open a saved .html file, and check the result at desktop, tablet or phone width.
How to view an HTML file
- Paste HTML into the
HTMLpane, or pressOpen fileor drop an .html, .htm or .xhtml file anywhere on the tool.Exampleloads a small demo page. - Read the
Previewpane. It redraws about a quarter of a second after you stop typing. - Pick a width in the bar above the panes:
Fitfills the pane, while1280,768and375set the frame to that many CSS pixels and scroll sideways when the pane is narrower.Expand panegives the preview the whole tool; Esc returns. - Press
Prettify sourceto reformat the source with Prettier, embedded CSS and JavaScript included. It replaces the text in theHTMLpane. - Check the line under the preview for the page title and what the sandbox held back: scripts, inline handlers, external resources and forms.
Example
A newsletter snippet with a tracking pixel, a linked stylesheet, an inline logo and a script. Only the inline logo and the inline styles reach the preview.
<!doctype html>
<html>
<head>
<title>June update</title>
<link rel="stylesheet" href="https://cdn.example.com/mail.css">
<style>h1 { color: #0a7; }</style>
</head>
<body>
<img alt="logo" src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'/%3E">
<h1>What shipped in June</h1>
<p>Read the <a href="https://example.com/blog">full post</a>.</p>
<img src="https://track.example.com/open.gif?id=42" width="1" height="1" alt="">
<script>fetch("https://track.example.com/read")</script>
</body>
</html>524 B · 15 lines · 12 elements
title: June update
1 script not run
2 external resources not loaded
1 data: URI shownDetails
- The preview is an
<iframe>with an emptysandboxattribute and the page insrcdoc, so none ofallow-scripts,allow-same-origin,allow-forms,allow-popupsor top navigation is granted. Scripts,onclick-style handlers andjavascript:links do nothing, and forms cannot submit. - Before the page is drawn, a Content-Security-Policy meta tag goes in front of it:
default-src 'none', with onlydata:URIs allowed for images, media, fonts and stylesheets, plus inline styles. Relative URLs are blocked as well as remote ones, so rendering makes no requests at all, not even to tomz.dev. DNS prefetching is switched off, and a<meta http-equiv="refresh">or a preconnect hint is disabled by renaming its attribute. - Links are adjusted in the preview only:
#sectionlinks scroll the frame, relative links do nothing when clicked, and links to other sites are blocked by the site's frame policy. TheHTMLpane always keeps your text exactly as typed or opened. - Files are decoded the way a browser picks an encoding, simplified: a byte order mark first, then a
<meta charset>in the first 1024 bytes, then UTF-8, and Windows-1252 if the bytes are not valid UTF-8. The choice is shown in the line under the source asdecoded as …. - The counts come from a light tokenizer, not a full parser.
elementsis the number of start tags in the source, so tags the browser adds by itself, such as a missing<body>, are not included. External resources aresrc,srcset,poster, stylesheet and icon links, SVG image references and CSSurl()or@import; ordinary link targets are not counted, since nothing loads until they are clicked. - The frame starts on a white background in both site themes, as a fresh browser tab would.
Limits
- No JavaScript ever runs, so pages that build their content with scripts, such as React or Vue apps and many pages saved with Save Page As, show up blank or half-finished.
- Remote images, stylesheets and web fonts never load. To see a page with its styles, paste the CSS into a
<style>block; to see an image, turn it into adata:URI first. - Large files have no size limit: a page over 1,000,000 characters is read with a progress line and Cancel, and after an edit it waits for
Show preview, though the browser can still take a while to draw a very long page. The source pane is a plain text box with no syntax highlighting or tag matching, and nothing is saved when you leave the page. - Prettify needs HTML that Prettier can parse; badly broken markup gets an error instead of a guess. It can also change whitespace between inline elements in rare cases, which may shift the rendering slightly.
- One page at a time: an .html file's linked CSS, images or other pages from the same folder are not read, even if you drop them together.
FAQ
Is it safe to open an untrusted HTML file here?
It is drawn in a sandboxed frame that has scripts, forms, pop-ups and same-origin access switched off, under a policy that only lets data: URIs load. A tracking pixel or remote script in the file cannot reach its server from the preview.
Why are the images missing from my page?
Images on another server, or next to the file on your disk, are blocked on purpose, so the preview never makes a network request. Images embedded as data: URIs show normally.
Can I preview HTML with JavaScript?
No. The sandbox never runs scripts, including inline event handlers. The counts under the preview tell you how many scripts and handlers were skipped, so you know the page may look different in a normal browser.
How do I check how a page looks on a phone?
Press 375 in the width bar to make the frame 375 CSS pixels wide, which triggers the page's own media queries for narrow screens. 768 and 1280 do the same for tablet and desktop widths.
Runs entirely in your browser. Nothing is uploaded.