How to Export HAR Files Using Safari Web Inspector
This article provides a direct guide on how the Network tab in the Safari Web Inspector captures and exports HTTP traffic logs into the HTTP Archive (HAR) file format. It covers enabling the developer tools in Safari, recording network requests, how the browser structures this data, and the exact steps required to extract the logs for debugging and performance analysis.
How the Network Tab Processes HTTP Traffic
The Network tab in Safari's Web Inspector acts as a real-time monitor for all network requests and responses occurring within a active browser tab. When open, it automatically intercepts and logs data regarding HTML documents, stylesheets, scripts, media, and API calls.
To allow for external analysis, Safari compiles these captured metrics—including request and response headers, cookies, payload bodies, HTTP status codes, and detailed timing metrics (such as DNS lookup, TCP handshake, and Time to First Byte)—and serializes them into a standardized JSON-based structure. This structure is the HAR format, which can be exported directly from the user interface.
Step 1: Enable the Safari Web Inspector
Before you can access the Network tab, you must enable Safari's developer tools, which are hidden by default.
- Open the Safari browser.
- Click Safari in the top menu bar and select Settings (or Preferences on older macOS versions).
- Navigate to the Advanced tab.
- At the bottom of the window, check the box next to Show features for web developers (or Show Develop menu in menu bar).
- Close the Settings window.
Step 2: Open the Network Tab and Capture Traffic
Safari only logs HTTP traffic while the Web Inspector is actively open.
- Navigate to the webpage where you want to capture traffic.
- Right-click anywhere on the page and select Inspect
Element, or press
Command + Option + Ion your keyboard. - In the Web Inspector panel that appears, click the Network tab at the top.
- (Optional) If the issue you are debugging occurs across multiple page loads or redirects, check the Preserve Log option (often represented by an icon or found in the filter bar, depending on your Safari version) so previous requests are not cleared upon navigation.
- Refresh the webpage (
Command + R) or perform the specific user actions you need to log. You will see the Network table populate with individual HTTP requests in real time.
Step 3: Export the Logs as a HAR File
Once the necessary HTTP traffic has been recorded in the Network tab, you can extract it using the built-in export function.
- Locate the Export button in the upper-right corner of the Network tab's toolbar (next to the trash can icon). Alternatively, you can right-click on any specific file listed in the network log table and select Export HAR.
- A macOS file dialog window will appear.
- Enter a name for your log file. Safari automatically appends the
.harfile extension. - Choose your destination folder and click Save.
Security Consideration
The exported HAR file contains an exact replica of the network session. This includes sensitive information such as authentication tokens, session cookies, API keys, and any unencrypted personal data submitted in forms during the recording. Always review and sanitize the HAR file using a text editor before sharing it with third parties.