Skip to content

Paste HTML or open a file to see it rendered as you type. Check it at phone width, and format messy markup in one click.

Format indent:
HTML
Preview
The rendered page appears here
Ctrl+EnterFormatCtrl+Shift+CCopy HTMLThe preview runs in a sandbox with no access to this page, your cookies, or your storage.

Share this tool

Found it useful? Help a fellow developer discover it.

https://developertoolkit.dev/tools/html-viewer

What this HTML viewer does

Paste HTML on the left and the HTML viewer renders it on the right, the way a browser would, updating as you type. It takes a full document with <html> and <head>, or a fragment such as a single table or an email template. Inline <style> blocks render straight away, and <script> tags run once you tick Run JavaScript, so you can check a component, a saved page or a snippet from a pull request without creating a file or starting a dev server.

The preview width buttons resize the frame to 768px for a tablet and 375px for a phone, which is enough to see whether a layout collapses the way it should. The page title from <title> shows in the preview header, and Open file loads an .html file from your computer without uploading it.

Viewing HTML emails and untrusted pages safely

The preview runs in a sandboxed frame with its own isolated origin and its own JavaScript scope. Code inside it cannot read this page, your cookies or your local storage, cannot redirect this page, and cannot open popups, submit forms or show dialogs. Images, scripts, stylesheets and fonts hosted on other sites are blocked, and so are fetch requests, WebSockets, WebRTC connections, connection hints such as preconnect, and writes to your clipboard. With JavaScript off, which is the default, nothing in the preview can contact another server. That matters for HTML emails: most marketing emails carry a 1×1 tracking pixel that tells the sender when and where the message was opened. Here, that pixel never loads. The viewer counts the remote resources it blocked and tells you under the editor.

To see an image in the preview, embed it as a data URI. The Image to Base64 converter gives you a ready-made <img> tag. Only tick Run JavaScript for HTML you trust. Even inside the sandbox, a script written for the purpose can sometimes make the browser open a connection that reveals your IP address to another server. It still cannot read anything from this page.

HTML formatter and beautifier

Format HTML (or Ctrl+Enter) rewrites the markup with one element per line and consistent indentation, using 2 or 4 spaces. Inline elements such as <strong> and <a> stay on their line, and the contents of <pre> and <textarea>are left exactly as they were. Embedded CSS and JavaScript are indented too. It is the quickest way to read minified HTML from a build tool, a CMS export or a browser's view source.

Before

<nav><ul><li><a href="/">Home</a></li><li><a href="/docs">Docs</a></li></ul></nav>

After

<nav>
  <ul>
    <li><a href="/">Home</a></li>
    <li><a href="/docs">Docs</a></li>
  </ul>
</nav>

How to use

  1. Paste HTML into the editor, click Open file, or click Load an example to see how it works.
  2. Watch the preview update as you edit. Switch between full width, tablet and mobile at the top.
  3. Click Format HTML to indent the code, choosing 2 or 4 spaces first.
  4. Copy the code from the editor header, or click Download .html to save it as a file.

Frequently Asked Questions

How do I view an HTML file online?

Click Open file and choose the .html file, or paste its contents into the editor. The rendered page shows in the preview straight away, next to its source. The file is read by your browser and never uploaded.

Does JavaScript run in the HTML viewer?

Only when you tick Run JavaScript, which is off by default. Then inline scripts and event handlers such as onclick run inside a sandboxed frame with its own JavaScript scope that cannot reach this page, your cookies or your storage. Dialogs such as alert(), popups, form submissions, network requests, WebRTC and clipboard writes stay blocked. A loop that runs for more than a second without pausing is stopped, so a mistake like while (true) cannot freeze the page. Turn it on only for HTML you trust: a script built for the purpose can sometimes make the browser reveal your IP address to another server.

Why are some images or styles missing in the preview?

Resources loaded from other sites, such as images on a CDN, Google Fonts or a Bootstrap stylesheet, are blocked so the preview never contacts another server. Inline styles, <style> blocks and images embedded as data URIs all render normally.

Why do links not open when I click them in the preview?

Opening a link or a popup would let the previewed page send data to another site in the URL, so the preview blocks it. To follow a link, copy its address from the HTML in the editor.

How do I format or beautify HTML?

Paste the HTML and click Format HTML, or press Ctrl+Enter (Cmd+Enter on a Mac). Each block element moves to its own line with consistent indentation, and embedded CSS and JavaScript are indented as well. Pick 2 or 4 spaces in the toolbar first.

Can I check how a page looks on a phone?

Switch the preview to Mobile (375px) or Tablet (768px). The frame narrows to that width, so CSS media queries respond as they would on a real device. It does not emulate touch or a mobile user agent.

Is my HTML uploaded or saved anywhere?

No. The HTML viewer runs entirely in your browser. Nothing you paste or open is sent to a server, and nothing is saved after you close the tab, so download the file if you want to keep your edits.

Related Tools