HTML viewer and online HTML editor

Paste HTML, open a file or edit the example. The preview updates as you type and runs in a sandbox, so the code cannot touch this page.

How to use the HTML viewer

  1. Paste your code into the editor, or press Open file to load an .html file from your device.
  2. Watch the preview on the right. Switch between Mobile (390px), Tablet (768px) and Desktop to check the layout at each width.
  3. Edit until it looks right and press Download .html to keep the result.

Turn off Update as I type when you work on a large page or on scripts that should only run once; the preview then refreshes only when you press Run.

What people use it for

  • Checking a snippet before pasting it into a project. Code from a chatbot, a forum answer or a colleague renders here first, without touching your repository.
  • Reading an HTML attachment on a phone. Email clients often show .html files as raw text. Open the file here and it renders as a page.
  • Testing a responsive layout. The Mobile and Tablet buttons resize the preview to real device widths, so media queries and Tailwind breakpoints switch the way they would on the device.

What the sandbox allows

The preview is an iframe with sandbox="allow-scripts" and nothing else. Your HTML, CSS and JavaScript run, and external resources such as Google Fonts or a Tailwind CDN script load normally. The frame gets an opaque origin, so it cannot read cookies or storage from img2html.com, cannot submit forms, open popups or navigate this tab. Output from console.log goes to your browser developer tools.

HTML viewer questions

Is my HTML uploaded anywhere?

No. The code stays in this browser tab. The preview is built from a local string (an iframe srcdoc), so nothing is sent to IMG2HTML or to anyone else.

Does JavaScript run in the preview?

Yes, inside a sandboxed iframe with a unique, opaque origin. Scripts can change the preview, but they cannot read this page, its cookies or its storage. Forms, popups and top-level navigation are blocked.

Why are my images or CSS files missing?

Relative paths such as images/logo.png or style.css have nothing to resolve against when you paste code or open a single file. Use absolute URLs (https://...) or put the CSS inside a <style> tag.

Can I open an .html file from my computer or phone?

Yes. Use Open file, pick the .html or .htm file and it loads into the editor and the preview. This is also the quickest way to read an HTML email attachment on a phone.

How do I save my changes?

Download .html saves the current code as a file. Nothing is stored between visits, so download before you close the tab.