How to preview HTML online
- Paste HTML into the HTML source box, or press Upload .html to open a file. Press Sample to try it with example markup.
- The Live preview on the right updates as you type, rendered inside a sandboxed frame.
- Use Mobile, Tablet or Desktop to check the layout at different widths.
- Press Format HTML to reindent the source, Copy to copy it, or Open in new tab to view it full-page from a local blob URL (nothing is uploaded).
Is it safe to view HTML you don't trust?
The preview is an <iframe sandbox> using srcdoc, which is the browser's own mechanism for isolating untrusted content. Two choices make it safe by default:
- Scripts are off until you turn them on. With "Run scripts" unticked, the frame's
sandboxattribute has noallow-scriptstoken, so no<script>, inline event handler orjavascript:link can execute at all — the browser blocks it before your code ever runs. - Even with scripts on, the frame never gets
allow-same-origin. A sandboxed frame with scripts but no same-origin token is treated by the browser as coming from a unique, opaque origin: it cannot read this page's cookies, localStorage or DOM, cannot make same-origin requests as freetoolhq.com, and cannot navigate the top-level page. That combination is the standard safe pattern for previewing arbitrary HTML.
Nothing you paste is ever sent anywhere: rendering happens entirely inside your browser. "Open in new tab" is the one exception worth knowing about — it opens your HTML as a normal, un-sandboxed browser tab (exactly like double-clicking a saved .html file would), so only use it once you're happy with what the sandboxed preview showed you.
Format HTML: a simple indenter
Minified or hand-mangled markup, all on one or two lines, is hard to read:
<!DOCTYPE html><html><head><title>Hi</title></head><body><h1>Hello</h1><p>World</p><img src="a.png"><br></body></html>Format HTML adds line breaks and indentation based on nesting:
<!DOCTYPE html>
<html>
<head>
<title>
Hi
</title>
</head>
<body>
<h1>
Hello
</h1>
<p>
World
</p>
<img src="a.png">
<br>
</body>
</html>Void elements — <img>, <br>, <input>, <hr>, <meta>, <link> and a handful of others — never have a closing tag in HTML, so they don't add a nesting level either. <script> and <style> contents are copied through untouched, so your JavaScript and CSS are never reformatted or reflowed.
Viewport width presets
Responsive pages look different at different widths. Mobile sets the preview to 375px (a common phone width), Tablet to 768px, and Desktop removes the limit so the frame fills the available space. This checks layout quickly; it does not fully emulate a device (pixel density, touch input, real network conditions), so confirm important pages on real devices too.
HTML viewer vs HTML renderer vs online HTML editor
- HTML viewer or renderer: takes HTML source and shows the page it produces. That's what this tool does, live, as you type.
- Online HTML editor: usually adds a syntax-highlighted code editor, multiple files (HTML/CSS/JS) and often a console — closer to a lightweight CodePen. If you need that, this page is intentionally simpler: one HTML source, one safe preview.
- HTML formatter: only reindents the source; it doesn't render anything. The Format HTML button here covers that part too.
Whichever name brought you here — "view HTML online", "HTML preview", "HTML renderer" or "HTML code viewer" — the job is the same: turn markup you're not currently able to open as a page (a snippet in a ticket, an email template, an exported fragment, a file a colleague pasted into chat) back into something you can actually look at, without saving a file or spinning up a server first.
Common ways people use an HTML viewer
- Email templates. Marketing HTML emails are full of inline styles and table layouts that render very differently from a normal page; paste the exported HTML here to check it before sending.
- Reviewing a pull request. When a diff includes a rendered fragment or an email/report template, pasting the changed HTML gives a quick visual check without pulling the branch.
- Untrusted or unknown HTML. A file attachment, a scraped page, or markup a client emailed you — look at it in the sandboxed preview first, with "Run scripts" left off, before deciding whether to trust it further.
- Quick prototyping. Sketch a component or layout in plain HTML and CSS and see it update as you type, with no build step.
More developer tools
- XML formatter & validator: pretty print, minify and validate XML with the same line-and-column error reporting.
- JSON formatter & validator: format, minify and validate JSON.
- XML to JSON converter for turning markup-shaped data into JSON.
Frequently asked questions
How do I view my HTML file?
Double-clicking an .html file opens it in your default browser as a normal, un-sandboxed page, which is fine for a file you already trust. To look at HTML from somewhere else without running it as a full page, or to preview a snippet that isn't a complete file, paste or upload it here and it renders instantly in a locked-down preview instead.
What is the best HTML viewer?
For a quick, private look at a page or snippet, a browser-based viewer like this one needs no install and never uploads what you paste. For building and debugging a whole site, your browser's own DevTools (right-click → Inspect) or an editor with a live-preview extension goes further.
What is an HTML viewer?
A tool that takes HTML source (pasted, typed or from a file) and renders it as a web page would, without needing to save a file or start a server. This one also formats the source and lets you check it at mobile, tablet and desktop widths.
Why can't I open an HTML file in my browser?
A few common reasons: the file has a .txt extension instead of .html so the browser shows it as text; it was downloaded but blocked by antivirus/Gatekeeper; or you're looking at HTML pasted into an email or chat rather than a saved file, which has nowhere to "open" from. Paste that text here instead and it renders immediately.
Do scripts in my HTML run?
Not unless you turn on "Run scripts". By default the preview is a sandboxed iframe with no script execution at all, so you can safely paste HTML from anywhere and look at it first. Turning scripts on adds only sandbox="allow-scripts", never allow-same-origin, so even then the preview cannot read this page's cookies or storage, or reach outside its frame.
Is it safe to preview HTML I don't trust?
Safer than opening it as a file, because of the sandbox above, but "safer" is not "risk-free": a script-enabled preview can still show misleading content, open a fake login look-alike, or try a pop-up (which the sandbox also blocks unless allowed). Treat any HTML you did not write the way you would treat an email attachment, and keep "Run scripts" off unless you need it.
What is the difference between an HTML viewer and an HTML renderer?
"Viewer" and "renderer" describe the same thing here: turning HTML source into the page it describes. Some tools use "renderer" to emphasize live updates as you type, which this one also does.
Can I test how my HTML looks on mobile?
Yes. The Mobile (375px) and Tablet (768px) buttons resize the preview frame to those common widths so you can check a responsive layout without opening real devices; Desktop removes the limit.
Does formatting change my HTML?
Format HTML only adds or removes indentation and line breaks between tags; it does not add, remove or reorder tags, attributes or text. <script> and <style> contents are left untouched so your JS and CSS are never rewritten.
Is my HTML uploaded anywhere?
No. Rendering, formatting and the live preview all happen in your browser; nothing you paste or upload is sent to a server, logged or saved. Only your width and "Run scripts" settings are remembered on your device.