Free tool
HTML Viewer & Formatter
Paste HTML to see a safe, sandboxed live preview where scripts never run, then beautify or minify the source. Private: nothing leaves your browser.
Runs entirely in your browser. Nothing you type or upload is sent to our servers.
How to use the HTML viewer
- Paste HTML into the editor, or open an .html file from your computer. The preview updates as you type.
- Use the width buttons to check how the markup lays out at phone, tablet and full width.
- Choose Beautify to indent the source so it is easy to read, or Minify to shrink it. The result replaces the editor text, so copy it or download it as an .html file.
Why the preview is safe
Pasted HTML is untrusted: it can contain scripts, forms that submit data, and links that open other pages. This tool shows it inside an iframe whose sandbox attribute is empty, which is the strictest setting. In that state the browser refuses to run scripts, treats the content as coming from a unique, empty origin (so it cannot read this page, its cookies or its storage), and blocks forms, popups and navigation of the parent page. A Content-Security-Policy placed before your markup adds a second lock: scripts are forbidden and, unless you switch it on, so is every network request. The text is handed to the iframe through srcdoc, never inserted into this page's own DOM.
Worked example: beautify
This one-line snippet:
<div class="card"><h2>Hello</h2><p>Some <b>bold</b> text</p><ul><li>One</li><li>Two</li></ul></div>becomes, with a 2-space indent:
<div class="card">
<h2>Hello</h2>
<p>Some <b>bold</b> text</p>
<ul>
<li>One</li>
<li>Two</li>
</ul>
</div>The inline <b> stays inside its paragraph, the repeated spaces in "bold text" collapse to one (as the browser would show them), and each list item gets its own line.
Worked example: minify
A formatted snippet with a comment and blank space, <div class="card"><h2>Hello</h2><p>Some <b>bold</b> text</p><!-- note --></div> with its line breaks and indentation, minifies to:
<div class="card"><h2>Hello</h2><p>Some <b>bold</b> text</p></div>What gets blocked, and what still works
- Blocked:
<script>tags, inline handlers such asonclick, form submission, popups, and (by default) requests for images, fonts and stylesheets on the internet. - Works: all HTML and CSS written in the page,
<style>blocks, inline styles, SVG, and images supplied asdata:URLs.
Working with Markdown rather than HTML? Use the Markdown to HTML converter. To tidy data instead of markup, try the JSON formatter, and to see what changed between two versions of a page, use Text Compare.
Frequently asked questions
Is it safe to paste HTML I do not trust?
Yes. The preview runs inside an iframe with an empty sandbox attribute, which blocks scripts, forms, popups, plugins and access to this page, its cookies and its storage. A Content-Security-Policy inside the preview also forbids scripts and, by default, any network request. Your HTML is never sent to a server.
Why does my JavaScript not run in the preview?
Scripts are blocked on purpose, so pasted code cannot do anything to you or to this site. The tool tells you how many script tags and event handlers it found. To test behavior, use a code editor or your browser developer tools. This tool is for checking markup, layout and styles safely.
Why are my images, fonts or stylesheets missing?
By default the preview does not fetch anything from the internet, which also protects your privacy. Images and styles given as data: URLs and CSS written in the page itself work. To load pictures, fonts and stylesheets from https addresses, turn on "Load images and styles from the web". Scripts stay blocked either way.
Does beautifying change how my page looks?
It should not. The formatter only changes whitespace between elements, keeps text and attribute values unchanged, and leaves the contents of pre, textarea, script and style blocks structurally intact. One caveat is that browsers show a single space between inline elements, so keep text and inline tags together as the formatter does.
What is the difference between beautifying and minifying?
Beautifying adds line breaks and indentation so people can read and edit the markup. Minifying removes comments and unnecessary whitespace so the file is smaller to send over a network. Both produce HTML that renders the same. The tool shows the size before and after so you can see the saving.
Can it load a live web page from a URL?
No. It renders the HTML text you paste or open from your computer. Fetching other sites would need a server to get around browser security rules, and that would mean sending your requests to us. To inspect a live page, use your browser: view the source, copy it, and paste it here.
How much HTML can I paste?
Up to one million characters, which is far larger than a typical page. Anything beyond that is rejected with a message rather than freezing your browser. The preview updates a moment after you stop typing, so large documents stay responsive.
Does it work on a phone?
Yes. The editor and preview stack vertically on narrow screens, the text areas are large, and the width buttons let you check how your markup looks at a phone, tablet or full width. Nothing needs installing and no account is needed.
Link to this tool
Found it useful? Copy a link for your page, newsletter or documentation.
Get new tools and guides by email
Optional. The tool above works without signing up.
More free tools
Browse all developer tools or the full list of free tools.
- Text Compare & Diff CheckerCompare two texts side by side or inline and see every added, removed and changed line or word. Options to ignore case and whitespace. Nothing is uploaded.
- JSON to CSV & CSV to JSON ConverterConvert JSON to CSV or CSV to JSON with nested-object flattening, any delimiter and correct RFC 4180 quoting. Large files are handled in your browser.
- Unix Timestamp ConverterConvert Unix timestamps in seconds, milliseconds, microseconds or nanoseconds to UTC, local and time-zone dates, and back. Includes ISO 8601 and the current time.
- Binary, Decimal & Hex Converter with Number to WordsConvert whole numbers between binary, octal, decimal and hexadecimal exactly, even for very large values, and spell any number out in words.
- Unit ConverterConvert length, weight, temperature, volume, area, speed and data size with exact factors, such as 1 inch = 2.54 cm. Includes inches to cm and kg to lbs.
- HEIC to JPG ConverterConvert iPhone HEIC photos to JPG in your browser with quality control. Works where your browser can open HEIC. Your photos are never uploaded.