Inside the Apple Safari .webarchive File Format

This article explores the Apple Web Archive (.webarchive) file format used by the Safari web browser to save complete web pages for offline viewing. It explains the core purpose of the format, its underlying binary property list (plist) architecture, and the exact mechanism it uses to bundle HTML, CSS, JavaScript, and image assets into a single, self-contained file.

What is the .webarchive Format?

The .webarchive file format is a proprietary standard created by Apple for the WebKit engine, which powers the Safari browser on macOS and iOS. When a user saves a webpage in Safari, the browser uses this format by default. Unlike saving a standard HTML file—which either loses external assets or dumps them into a separate, messy folder—a .webarchive file captures the entire webpage as a single file. This allows users to view the page offline exactly as it appeared when saved, with all styling and media intact.

The Underlying Technology: Property Lists

Despite functioning like a zip file, a .webarchive file is not a compressed archive in the traditional sense. Instead, it is an Apple Property List (plist) file, typically saved in a binary format for space and speed efficiency.

Property lists are structured data files used extensively across Apple operating systems to store serialized objects. Because a .webarchive is a binary plist, opening it in a text editor will reveal the header bplist00 followed by unreadable binary code. However, using Apple's native command-line utility (plutil), a .webarchive can be converted into an XML file, revealing a human-readable tree of keys and values.

How HTML, CSS, and Images are Bundled

To merge dozens of separate web files into one document, Safari serializes the loaded webpage into a structured hierarchy of dictionaries and arrays within the property list. This hierarchy relies on three main organizational keys:

  • WebMainResource: This dictionary holds the primary file of the webpage, which is almost always the foundational HTML document.
  • WebSubresources: This is an array of dictionaries containing all the external files required to style and populate the page. Every linked CSS stylesheet, JavaScript file, font, and image is given its own dictionary entry inside this array.
  • WebSubframeArchives: If the webpage contains inline frames (<iframe>), the contents of those frames are saved as separate, nested web archives under this key, following the exact same structure as the parent archive.

Data Storage and Mapping

To ensure the browser knows how to reassemble the bundled files, every item inside the WebMainResource and WebSubresources sections is saved with specific metadata keys:

  • WebResourceData: This holds the actual file content. In the default binary format, images, CSS, and HTML are stored as raw byte streams. If the archive is converted to XML, this data is encoded as Base64 text strings.
  • WebResourceURL: This records the original web address (URL) where the asset was hosted when the page was saved.
  • WebResourceMIMEType: This defines the file type, such as text/html, text/css, application/javascript, or image/jpeg.
  • WebResourceTextEncodingName: For text-based files like HTML and CSS, this specifies the character encoding, such as UTF-8.

How Safari Reconstructs the Webpage

When you open a .webarchive file, Safari parses the binary property list and loads the WebMainResource data into the browser, rendering the core HTML.

As the HTML parser reads the code, it encounters links to external CSS files and images via their original URLs. Instead of reaching out to the internet to download these files, Safari intercepts the requests. It cross-references the requested URLs with the WebResourceURL keys stored in the WebSubresources array. When it finds a match, Safari reads the WebResourceMIMEType to understand how to handle the file, and then injects the raw WebResourceData directly into the webpage. This internal routing allows the complex, multi-file webpage to render seamlessly from a single document without an active internet connection.