How to Convert HAR Files to OpenAPI Specs

Learn the step-by-step process of converting HTTP Archive (HAR) files into OpenAPI 3.0 specifications for better API documentation and testing.

Working with APIs often involves understanding their structure, endpoints, and data formats. While many APIs come with comprehensive documentation, you may encounter situations where documentation is missing, outdated, or you need to reverse-engineer an API from existing traffic. This is where converting HAR files to OpenAPI specifications becomes invaluable.

In this guide, we will walk through the complete process of capturing HTTP traffic as a HAR file and converting it to an OpenAPI 3.0 specification using ProxyKit's free HAR file viewer.

What is a HAR File?

A HAR (HTTP Archive) file is a JSON-formatted log of a web browser's interaction with a website. It captures all HTTP requests and responses, including:

HAR files are incredibly useful for debugging, performance analysis, and understanding how web applications communicate with their backend APIs.

What is OpenAPI?

OpenAPI Specification (formerly known as Swagger) is the industry-standard format for describing REST APIs. An OpenAPI spec defines:

Having an OpenAPI specification enables automatic code generation, interactive documentation, and comprehensive API testing.

Step-by-Step: HAR to OpenAPI Conversion

Follow these steps to convert your HAR file to an OpenAPI specification:

  1. Capture the HAR file from your browser

    Open Chrome DevTools (F12), go to the Network tab, perform the API operations you want to document, then right-click and select "Save all as HAR with content".

  2. Upload to ProxyKit HAR Viewer

    Visit the ProxyKit HAR viewer and drag-and-drop your HAR file or click to upload. The tool will parse and display all captured requests.

  3. Review and filter endpoints

    Use the method and status filters to focus on relevant API endpoints. You can search for specific paths or response content to find the endpoints you need.

  4. Export to OpenAPI

    Click the "OpenAPI" export button to generate the specification. Choose between JSON or YAML format based on your preference.

  5. Refine the specification

    Review the generated spec and add descriptions, adjust schemas, and organize endpoints as needed for your documentation.

How ProxyKit Generates Smart OpenAPI Specs

ProxyKit uses intelligent algorithms to create clean, usable OpenAPI specifications from your HAR data:

Path Parameter Detection

The converter automatically identifies path parameters by analyzing similar endpoints. For example, if your HAR contains:

GET /api/users/123
GET /api/users/456
GET /api/users/789

ProxyKit recognizes these as variations of the same endpoint and generates:

GET /api/users/{userId}

Request/Response Schema Inference

The tool analyzes JSON request and response bodies to infer data types and generate schemas. For a response like:

{
  "id": 123,
  "name": "John Doe",
  "email": "john@example.com",
  "active": true
}

ProxyKit generates an OpenAPI schema with appropriate types:

type: object
properties:
  id:
    type: integer
  name:
    type: string
  email:
    type: string
    format: email
  active:
    type: boolean

Multiple Response Status Handling

If your HAR file contains multiple responses for the same endpoint with different status codes (200, 400, 404, 500), ProxyKit includes all of them in the specification for comprehensive documentation.

Pro Tip

For the best OpenAPI output, capture diverse API interactions in your HAR file. Include successful responses, error cases, and requests with different query parameters to generate more complete documentation.

Use Cases for HAR to OpenAPI Conversion

Converting HAR files to OpenAPI specs is valuable in several scenarios:

Exporting to Postman

In addition to OpenAPI, ProxyKit also supports exporting your HAR data to Postman collections. This is useful when you want to:

Simply click the "Postman" export button in the HAR viewer to download a ready-to-import collection file.

Best Practices for HAR Capture

To get the most accurate OpenAPI specification from your HAR file:

  1. Clear the network log before starting - This ensures you only capture relevant requests
  2. Perform complete user flows - Include all CRUD operations (Create, Read, Update, Delete) for each resource
  3. Capture edge cases - Include requests that trigger validation errors or 404 responses
  4. Filter out static assets - Focus on API calls, not image or CSS requests
  5. Use realistic data - This helps generate accurate schemas and examples

Conclusion

Converting HAR files to OpenAPI specifications bridges the gap between observed API behavior and formal documentation. Whether you are reverse-engineering an API, creating mock servers, or simply documenting existing endpoints, this workflow saves hours of manual documentation work.

ProxyKit makes this process simple and free - no signup required, no data stored on servers, just upload your HAR file and get your OpenAPI spec in seconds.

Ready to Convert Your HAR File?

Upload your HAR file now and generate an OpenAPI specification in seconds.

Open HAR Viewer