What Is a .MHT File?

MHTML document

📂Document
🏷️.mht
🎯message/rfc822

MHTML Web Archive (.mht, .mhtml)

Overview

MHTML (MIME Encapsulation of Aggregate HTML Documents) is a web page archive format that bundles an entire page - the HTML plus every image, stylesheet, and script it references - into a single file. Instead of the usual arrangement of one .html file next to a folder of assets, MHTML wraps everything in one MIME multipart container, the same encoding used for email attachments.

The format is specified in RFC 2557 and uses the .mht or .mhtml extension. Because it reuses email's MIME structure, an MHTML file is technically a valid message/rfc822 document, which is why file-type detectors frequently report it as such.

Technical Specifications

Format Details

  • MIME Type: message/rfc822 (also seen as multipart/related and application/x-mimearchive)
  • File Extensions: .mht, .mhtml
  • Category: Document
  • Specification: RFC 2557 (1999)
  • Encoding: MIME multipart/related, ASCII headers with base64 or quoted-printable bodies
  • Introduced by: Microsoft, in Internet Explorer 5

Identifying an MHTML File

MHTML files are plain text at the start, beginning with email-style headers:

From: <Saved by Blink>
Snapshot-Content-Location: https://example.com/page
Subject: Example Page
Date: Tue, 4 Mar 2025 10:12:44 -0000
MIME-Version: 1.0
Content-Type: multipart/related;
	type="text/html";
	boundary="----MultipartBoundary--abc123----"

There is no binary magic number, so detection relies on recognising the header block and the multipart/related content type. This is exactly the kind of file where extension-based guessing fails: an .mht archive and a saved email look nearly identical to a naive checker.

File Structure

An MHTML file is a sequence of MIME parts separated by a boundary string declared in the top-level header.

------MultipartBoundary--abc123----
Content-Type: text/html
Content-Transfer-Encoding: quoted-printable
Content-Location: https://example.com/page

<!DOCTYPE html><html><head><title>Example</title>...

------MultipartBoundary--abc123----
Content-Type: image/png
Content-Transfer-Encoding: base64
Content-Location: https://example.com/logo.png

iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAE

------MultipartBoundary--abc123------

Key structural rules:

  • The first part is the main HTML document.
  • Each subsequent part is a referenced resource, identified by its original URL in Content-Location.
  • Binary resources use base64 transfer encoding; text resources typically use quoted-printable.
  • The closing boundary carries two trailing hyphens.

When a browser opens the archive it rewrites the page's URLs to point at the embedded parts, so the page renders offline as it was captured.

History and Development

Microsoft introduced MHTML with Internet Explorer 5 as the "Web Archive, single file" save option, and the format was standardised as RFC 2557 in 1999. It became the usual way to email a rendered web page from Windows and to attach pages to reports and bug trackers.

Adoption outside Microsoft was uneven. Opera supported it natively for years, Chrome shipped it behind a flag before enabling the "Save as MHTML" path, and Firefox never supported it without an add-on. The modern Chromium engine writes MHTML when you choose Save page as → Webpage, Single File, and Microsoft Edge continues to read and write it.

Common Use Cases

  • Offline archiving: capturing a page exactly as it appeared, including images and CSS, for later reference.
  • Evidence and compliance: preserving a rendered page for legal, regulatory, or audit purposes where a screenshot is insufficient.
  • Bug reports: attaching a broken page in a single file so a developer sees the same markup and assets.
  • Email distribution: sending a full web page as one attachment rather than a folder of files.
  • Internal documentation: archiving intranet pages and knowledge-base articles that may later change or disappear.

How to Open an MHT File

On Windows

  • Microsoft Edge: opens .mht and .mhtml natively. Drag the file into a tab, or right-click and choose Open with → Microsoft Edge.
  • Internet Explorer: full native support on systems where it is still available.
  • Microsoft Word: opens MHTML and converts it to an editable document, useful when you want the text rather than the layout.

On macOS and Linux

  • Google Chrome / Chromium: open a tab and drag the file in, or use File → Open File. Chrome reads MHTML without any flag in current versions.
  • Opera: long-standing native support.
  • Firefox: requires an extension or a converter; there is no built-in reader.

From the command line

# Inspect the structure without rendering it
head -40 page.mht

Because the container is standard MIME, any email library can take it apart. In Python, email.message_from_file parses the archive and msg.walk() yields each embedded resource, with part.get_payload(decode=True) returning the decoded bytes and Content-Location giving the original URL.

Converting MHTML Files

To PDF

# Headless Chrome renders the archive and prints it
chrome --headless --disable-gpu --print-to-pdf=page.pdf page.mht

To plain HTML

Open the file in Edge or Chrome and re-save as Webpage, Complete, which writes an .html file plus an assets folder.

From HTML to MHTML

In Chrome or Edge, press Ctrl+S (Cmd+S on macOS) and choose Webpage, Single File.

Advantages

  • One file, no loose assets: nothing to lose when moving or emailing the archive.
  • Faithful rendering: CSS and images are preserved as they were served.
  • Text-based container: the outer structure is readable and scriptable with standard email libraries.
  • Standardised: RFC 2557 is a published specification, not a vendor-only format.

Limitations

  • Inconsistent browser support: Firefox needs an add-on, and support elsewhere has shifted over time.
  • No JavaScript execution state: dynamic content is captured as it stood at save time; scripts that fetch data will not work offline.
  • Large files: base64 encoding inflates binary assets by roughly 33%.
  • Security surface: an MHTML file can carry scripts and was historically involved in cross-site scripting issues in Internet Explorer. Treat archives from untrusted sources with the same caution as any downloaded web page.
  • Poor diffing: the format does not lend itself to version control or meaningful comparison between captures.
  • HTML: the markup that forms the main part of every MHTML archive.
  • EML: the email format that shares MHTML's MIME container structure.
  • PDF: the more common choice for fixed-layout page archiving.
  • EPUB: another single-file bundle of HTML and assets, aimed at publishing rather than archiving.

File Information

File Description

MHTML document

Category

Document

Extensions

.mht, .mhtml

MIME Type

message/rfc822

Related File Types

Other file types in the Document category you might also need:

Start Analyzing MHT Files Now

Use our free AI-powered tool to detect and analyze MHTML document files instantly with Google's Magika technology.

Try File Detection Tool