What is a HAR file and How Is It Generated?

| Coding Tutorials
What is a HAR file and How Is It Generated?

HAR files are great for providing additional information about HTTP requests.

Sometimes, when I'm troubleshooting issues on sites, we ask users to send us a HAR file. These are really useful for debugging difficult issues.

This article will help you creating HAR files and give you a little more information about it.

What is a HAR file?

A HAR file records HTTP requests in a JSON format. Some of the recorded information for each HTTP request are:

  • the URL
  • headers
  • cookies
  • request data
  • response
  • timings

HAR files can contain sensitive data, so make sure you store these files securely. 

How to generate a HAR file

One of the easiest ways to generate the HAR file is using Google Chrome. You can follow these steps:

  • Open the page you want to inspect on Google Chrome.
  • Select the Chrome menu at the top-right of the browser window.

chrome menu 1

  • Select More Tools > Developer Tools.
  • On the Developer Tools window, click on the Network tab.

chrome web dev tools 1

  • Check the box "Preserve Log" and make sure it is recording the log (red ball on the left).

chrome recording log 1

  • Refresh the page and navigate, or interact with the page until reproduced the problem you have been experiencing.
  • On the Network tab, click the right button on the list of requests and select "Save as HAR with content".

chrome save har 1

  • Save the HAR file to a convenient place.

 How to load or analyze the generated file

The HAR file is a text file, so you are able to load it on any Source Code or Text Editor. But in order to get a better visualization of the data, you can use analyzers like the one provided by Google: HAR Analyzer from the G Suit Toolbox


About the author

Anderson is from Maringá, Brazil and has been a developer since 2002. He's a full-stack dev who's worked on every layer of web, mobile and desktop systems.