HTML Preview
Paste any HTML code and see it rendered instantly. Test email templates, blog snippets, and custom HTML.
Related Tools
How to Use
- Paste Your HTML — Type or paste HTML code into the editor. The code is displayed in a monospace font. Use the Format button to auto-indent messy HTML (Ctrl+Z undoes it).
- See the Preview — The Preview tab renders your HTML in a sandboxed iframe as you type (300ms debounce). The Source tab shows the escaped HTML code. Stats display tag count, line count, and file size.
- Export — Copy the HTML to clipboard or download it as a complete .html file (a DOCTYPE and UTF-8 charset are added unless your code already has an html element).
About the HTML Preview Tool
HTML Preview renders any HTML you paste, from one paragraph to a full email template, in a sandboxed frame beside the code, and updates 300 ms after you stop typing. Use it to check a CMS snippet before publishing, look at HTML generated by another tool or an AI assistant, test an email layout in a real browser engine, or learn how markup turns into a page. A Format button re-indents messy code, and the Source tab shows the code as plain text.
How the preview works
Your HTML is placed inside the <body> of a small document with a UTF-8 charset, a mobile viewport and a few base styles: system font, 16px margin, images limited to the frame width, and tables with collapsed 1px borders. Your own CSS overrides them. A complete document with its own <html>, <head> and <style> also works, because the browser's HTML parser merges the duplicate tags and still applies your styles.
The frame uses srcdoc and sandbox="allow-scripts":
- Inline scripts run, but in an isolated origin. They cannot touch this page, its cookies or its storage.
- Dialogs such as
alert()are blocked, form submissions are blocked, and popups cannot open. - The site's security policy also applies, so external stylesheets, script files and web fonts do not load. Images from https addresses and
data:URLs do.
The stats line counts opening tags, lines and size in bytes.
Worked example: the Format button
Input:
<div class="card"><h2>Plans</h2>
<ul><li>Basic</li><li>Pro
<b>new</b></li></ul>
<p>$9/month.<br>Cancel anytime.</p>
<pre> keep this</pre></div>
After Format:
<div class="card">
<h2>Plans</h2>
<ul>
<li>Basic</li>
<li>Pro <b>new</b></li>
</ul>
<p>$9/month.<br>Cancel anytime.</p>
<pre> keep this</pre>
</div>
The rules: each nested block element is indented two spaces. A block that holds only inline content and is at most 120 characters long, tags included, stays on one line. Inline tags like <b>, <a> and <br> stay in the text flow. pre, textarea, script and style are copied exactly. Unclosed <li>, <p> or table cells are treated as closed when the next one starts. Formatting goes through the editor's undo history, so Ctrl+Z (Cmd+Z) restores the original in most browsers.
Limitations
- The preview uses your browser's rendering engine. Email clients and older browsers can display the same HTML differently, so treat it as a first check rather than a guarantee.
- External CSS, JavaScript files and web fonts are not loaded. Paste the CSS into a
<style>tag to see its effect. - Format only re-indents. It does not validate or repair HTML. It also collapses runs of spaces and line breaks in ordinary text to single spaces, which matters if your CSS uses
white-space: preoutside apreelement. - Nothing is saved. Download the file or copy the code before you close the tab.
Practical tips
- Tick Wrap to read long lines without scrolling sideways.
- Download .html saves your code as is when it already contains an
<html>tag. Otherwise it wraps the code in a minimal document with a doctype, charset, viewport and title. - For JavaScript you want to debug, with dialogs and a console, use the Code Playground. To show HTML code as text on a web page, escape it with the HTML Encoder & Decoder. To pull out just the text, use Strip HTML Tags.
The preview is built and rendered in your browser, so the HTML you paste is not sent to any server.
Frequently Asked Questions
How is this different from the Code Playground?
The Code Playground has three separate editors for HTML, CSS, and JavaScript with a combined preview. This HTML Preview is simpler — one textarea for HTML only, with instant rendering. Use the Playground for multi-file projects. Use this Preview for quick HTML testing, email template checks, and pasting single HTML snippets.
Can I preview email HTML templates?
Yes. Paste your email HTML (including inline styles, tables, and images) and see it rendered immediately. Email templates rely heavily on inline CSS and table layouts, both of which render in the preview iframe, and images load from https:// and data: URLs. The preview uses your browser's rendering engine, so it is a quick first check rather than a guarantee of how Outlook or Gmail will display the message.
Does the Format button fix my HTML?
The Format button auto-indents your HTML for readability: block elements go on their own lines with consistent 2-space indentation, short elements such as a list item stay on one line, inline formatting is left in place, and the contents of pre, textarea, script, and style elements are never changed. It does not fix broken HTML or add missing closing tags. It is a formatting/beautifier tool, not a validator.
Is CSS supported in the preview?
Yes. Inline styles (style attribute) and embedded style tags (<style>...</style>) both work in the preview. For security, the preview does not load external stylesheets or script files (for example from a CDN), so paste that CSS into a style tag instead. Images from https:// and data: URLs do load. The preview iframe has basic default styling for fonts and tables.
Is JavaScript executed in the preview?
Yes. Inline scripts run inside the sandboxed preview iframe, which cannot access this page. External script files and network requests to other websites are blocked. However, for full HTML + CSS + JS development, we recommend the Code Playground which provides separate editors for each language and a console panel for debugging.
Is my HTML sent to a server?
No. The preview uses an iframe with the srcdoc attribute — your HTML is rendered locally in your browser. Nothing is transmitted to any server. The Format and Copy features also work entirely client-side.