HTML File Viewer - Preview & View HTML Code

Open any .html or .htm file online and see the page rendered safely, with scripts off, next to its highlighted source code. Inspect the DOM, check the SEO and meta tags, list every link and image, then beautify the code or save it as PDF. Styles or scripts on their own? Open them in the CSS File Viewer or the JS File Viewer.

or paste HTML
Ctrl + Enter to view · Ctrl + V anywhere
Try a sample
Scripts off by default Split view SEO check No upload

How to open an HTML file online

  1. Open the HTML file. Drop a .html or .htm file anywhere on the page, browse for it, paste HTML code, or try a sample. Drop the whole folder to include its images and CSS.
  2. See the page. The Preview tab renders the page safely with scripts off. Switch between phone, tablet and desktop widths, or turn scripts on in a sandbox.
  3. Read the code. The Code tab shows highlighted source with folding, search and beautify, and Split puts code and preview side by side.
  4. Inspect and export. Check the DOM outline, SEO and meta tags, links, images and resources, then download the HTML, the text only, or print to PDF.

Keyboard shortcuts

  • Search the codeCtrl + F
  • Go to lineCtrl + G
  • Download the HTMLCtrl + S
  • Open a fileCtrl + O
  • Paste HTML to open itCtrl + V
  • Leave full screenEsc

HTML viewer features

Safe preview

The page renders in a locked sandbox with scripts off and the code cleaned first, so even a suspicious attachment can't do harm.

Readable source

Tags, attributes, inline CSS and JavaScript each get their own color, with line numbers, folding, search and a beautifier.

Split view

Code on one side, the rendered page on the other. Switch the preview between phone, tablet and desktop widths.

DOM outline

Every element in a tree you can unfold, with a find-by-CSS-selector box and a click-through to the source line.

SEO and meta check

Title and description length, a search result preview, Open Graph, headings, alt text and every link in one tab.

Local files too

Drop the saved page's folder and its images, CSS and fonts show up - straight from your disk.

Scripts on demand

Need the JavaScript? Switch it on and it runs in a sandbox with no access to this site or your data.

100% private

Your file is read by your browser and never uploaded. Close the tab and it is gone.

What is an HTML file?

An HTML file (HyperText Markup Language, extension .html or .htm) is a web page saved as text.

Tags like <h1>, <p> and <img> describe the headings, paragraphs and pictures, and the browser turns them into the page you see.

Styles usually live in separate CSS files and behavior in JavaScript files. That is why a page saved on its own can look plain or lose its pictures - the files next to it are missing.

You meet HTML files as saved web pages, email attachments, exported reports and documentation. This viewer shows both sides at once: the page as it looks, and the code that builds it.

How to open an HTML file on Windows, Mac, iPhone and Android

Every device has a browser that can show HTML, but each has its catches.

Windows

Double-click the file and it opens in your default browser. To see the code, press Ctrl + U in the browser, or right-click the file and choose Open with > Notepad.

Mac

Double-click to open it in Safari. TextEdit shows the formatted page unless you turn on Display HTML files as HTML code in its settings, under Open and Save.

iPhone and iPad

The Files app can only show a basic preview, and pictures next to the file usually don't load. Open this page in Safari, tap browse and pick the file from Files or iCloud Drive to see the page and its code.

Android

File managers often open HTML as plain text or ask for an app. Open this page in Chrome, tap browse and choose the file from Downloads or Drive.

View and beautify HTML source code

Pages from the web are often minified into a few enormous lines.

Press Beautified and the viewer re-indents every tag, including inline CSS and JavaScript, with 2 spaces, 4 spaces or tabs.

  • Search with match case, whole word or regular expressions, and jump to any line with Ctrl + G.
  • Fold any element to hide its children, or fold everything to see the page's skeleton.
  • Big files stay smooth - only the lines on screen are drawn, so a 50 MB export still scrolls instantly.

Click a line number in the Outline, SEO or Resources tab and the code view jumps right to that tag.

Is it safe to open an HTML file?

An HTML file can contain JavaScript, and attachments ending in .html or .htm are a favorite phishing trick.

Opened directly in a browser, such a file can show a convincing fake login form or send you elsewhere.

This viewer is built for that situation. The preview runs in a sandboxed frame with scripts blocked, forms disabled and the code cleaned by DOMPurify, so you can read the page and its code without it doing anything.

If a page asks for a password, a card number or a code from your phone, close it - real services do not send login pages as attachments.

Why won't my HTML file open correctly?

Most problems have a quick fix.

Images and styles are missing

The page points to files in a folder next to it. Drop the whole folder here, or use Add files - the Resources tab shows what is still missing.

I only see code, not the page

The file was opened in a text editor, or it was saved as .txt. Open it here and the Preview tab renders it.

The page is blank

Many modern pages build their content with JavaScript. Switch on Run scripts above the preview to let them run in the sandbox.

Strange characters like é or �

The file's character set does not match its contents. The viewer reads the <meta charset> tag and falls back sensibly; re-save the file as UTF-8 to fix it everywhere.

The file is a .mht or .mhtml

That is a web archive with the pictures packed inside. Chrome and Edge open those directly - drag the file into a browser window.

HTML vs HTM vs XHTML vs MHTML

These extensions look alike but differ in how strict they are and what they contain.

FormatExtensionWhat it isOpens here
HTML.htmlA standard web page as textYes
HTM.htmThe same thing - a three-letter extension from old Windows systemsYes
XHTML.xhtml, .xhtHTML written with strict XML rulesYes
SHTML.shtmlHTML with server-side includes, filled in by the web serverYes, includes are not filled in
MHTML.mht, .mhtmlA web archive with images packed into one fileNo - open it in Chrome or Edge

Convert HTML to PDF, text and more

Once the page is open, the export buttons cover the usual jobs.

  • HTML to PDF - press Print / PDF and choose Save as PDF. Shrink the result with Compress PDF.
  • HTML to text - Text only saves the readable words without any tags.
  • HTML to image - take a picture of the preview with Screen Capture.
  • Links and SEO - export every link as CSV from the SEO tab, then test a live site with the Broken Link Checker.

More formats to open? Browse all file viewers.

Frequently Asked Questions

Drop the .html or .htm file onto this page, click browse, or paste the code. You see the rendered page straight away, with the highlighted source one tab away.

Nothing is installed and nothing is uploaded - the file stays in your browser.

Open the file and choose the Code tab for color-coded source with line numbers, folding and search. Press Beautified to turn a one-line or messy file into neatly indented HTML.

Split shows the code and the rendered page side by side.

Be careful: HTML attachments are a common phishing trick, because they can show a fake login page. Here the preview runs with scripts switched off inside a locked sandbox, and the code is cleaned before it is shown.

Never type a password into a page that came as an attachment.

Most saved pages point to pictures and stylesheets in a folder next to them. A web page cannot read the folders on your computer by itself, so drop the whole folder, or press Add files and pick them.

The Resources tab lists every file the page needs and which ones are still missing.

Yes. Switch on Run scripts above the preview. The page then runs inside a sandbox with no access to this site, your cookies or your storage.

Scripts are off by default, so an unknown page can never do anything just by being opened.

Open the file and press Print / PDF, then choose Save as PDF in the print dialog. The page prints as it looks in the preview, without this site around it.

Need a smaller file afterwards? Use Compress PDF.

The SEO tab shows the title and meta description with their length, a search result preview, the canonical link, robots, Open Graph and Twitter tags, and the headings outline.

It also lists images without alt text and every internal and external link. To test the links on a live site, use the Broken Link Checker.

No. The page is read, analysed and rendered by your own browser and never leaves your device.

Recent files are only remembered if you switch that option on, and then only in this browser.

Guides & Tutorials

All 14 guides
Guide How to Tell What Format an Image File Is (5 Easy Ways) Read the guide Guide How to Open ZIP, RAR, 7Z & TAR.GZ Files Online (Without Installing Anything) Read the guide Comparison PNG vs JPG: Which Image Format Should You Actually Use? Read the guide