How to Convert HAR Files to cURL Commands: Complete Guide (2026)

HAR (HTTP Archive) files capture every network request your browser makes — headers, cookies, bodies, timings. Converting them to cURL commands lets you replay, debug, share, and automate those requests. This guide covers everything: what HAR files are, how to export them, how to convert to cURL, and how to handle sensitive data.

JSON

HAR file format (human-readable)

100%

of browser requests captured

3 tools

for HAR to cURL conversion

1 click

to export from Chrome/Firefox

1

What is a HAR File?

A HAR (HTTP Archive) file is a JSON-formatted log of all HTTP requests and responses made by a browser session. It was standardized by the W3C Web Performance Working Group and is supported by Chrome, Firefox, Safari, and Edge.

Complete request capture

HAR files record the full request: URL, method, headers, cookies, request body, response headers, response body, and timing data.

JSON format

HAR is plain JSON with a specific schema. You can open it in any text editor or parse it with any language.

Cross-browser standard

All major browsers export the same HAR format, making it a universal debugging artifact.

Security warning

HAR files contain all cookies and auth tokens from your session. Treat them like passwords — never share raw HAR files publicly.

HAR files contain sensitive data

HAR files capture session cookies, auth tokens, API keys, and passwords. Before sharing a HAR file with support teams or colleagues, sanitize it by removing or redacting sensitive headers and cookies.
2

How to Export a HAR File from Chrome

1

Open Chrome DevTools

Press F12 (or Cmd+Option+I on Mac) to open DevTools. Navigate to the Network tab.

2

Record network traffic

Make sure recording is active (the red circle button). Reload the page or perform the action you want to capture. All requests appear in the list.

3

Export the HAR file

Right-click anywhere in the request list and select "Save all as HAR with content", or click the download icon in the toolbar. Save the .har file to your computer.

4

Verify the export

Open the .har file in a text editor. You should see JSON starting with {"log": {"version": "1.2", "creator": {...}, "entries": [...]}}.

3

How to Export HAR from Firefox and Safari

ItemFirefoxSafari
Open DevToolsF12 or Ctrl+Shift+ICmd+Option+I (enable Dev menu first)
Tab to useNetwork tabNetwork tab
Export buttonGear icon → Save All as HARExport button (down arrow icon)
File format.har (JSON).har (JSON)
Response bodiesIncludedMay require "Record Network Content" enabled
4

Method 1: Convert HAR to cURL Using UnblockDevs Tool

The easiest method is to use the HAR to cURL converter on this site at /har-to-curl. It parses the HAR file, lists all requests, and generates cURL commands for each one. No data is sent to a server — conversion happens entirely in your browser.

Export HAR from browser

Open HAR to cURL Tool

Upload or paste HAR

Select request

Copy cURL command

Run or integrate

5

Method 2: Convert HAR to cURL Manually with JavaScript

If you need programmatic conversion — for example, in a test suite or CI pipeline — here is how to parse HAR entries and generate cURL commands:

jshar-to-curl.js
function harEntryToCurl(entry) {
  const { request } = entry;
  const parts = ['curl'];

  // Method (skip if GET since it's the default)
  if (request.method !== 'GET') {
    parts.push(`-X ${request.method}`);
  }

  // Headers (skip pseudo-headers and some auto-managed ones)
  const skipHeaders = new Set([
    ':method', ':path', ':authority', ':scheme',
    'content-length', // curl calculates this
  ]);

  for (const header of request.headers) {
    if (!skipHeaders.has(header.name.toLowerCase())) {
      parts.push(`-H ${JSON.stringify(`${header.name}: ${header.value}`)}`);
    }
  }

  // Cookies
  if (request.cookies && request.cookies.length > 0) {
    const cookieStr = request.cookies
      .map(c => `${c.name}=${c.value}`)
      .join('; ');
    parts.push(`-b ${JSON.stringify(cookieStr)}`);
  }

  // Request body
  if (request.postData) {
    const body = request.postData.text;
    parts.push(`-d ${JSON.stringify(body)}`);
  }

  // URL (must be last)
  parts.push(JSON.stringify(request.url));

  return parts.join(' \\
  ');
}

// Usage with a HAR file:
const fs = require('fs');
const har = JSON.parse(fs.readFileSync('session.har', 'utf8'));

har.log.entries.forEach((entry, i) => {
  console.log(`\n# Request ${i + 1}: ${entry.request.method} ${entry.request.url}`);
  console.log(harEntryToCurl(entry));
});
6

Method 3: Filter and Convert with Python

pythonhar_to_curl.py
import json
import sys

def har_to_curl(entry):
    req = entry['request']
    parts = ['curl']

    if req['method'] != 'GET':
        parts.append(f'-X {req["method"]}')

    skip = {'content-length', ':method', ':path', ':authority', ':scheme'}
    for h in req.get('headers', []):
        if h['name'].lower() not in skip:
            parts.append(f'-H {json.dumps(h["name"] + ": " + h["value"])}')

    if req.get('cookies'):
        cookie_str = '; '.join(f'{c["name"]}={c["value"]}' for c in req['cookies'])
        parts.append(f'-b {json.dumps(cookie_str)}')

    if req.get('postData', {}).get('text'):
        parts.append(f'-d {json.dumps(req["postData"]["text"])}')

    parts.append(json.dumps(req['url']))
    return ' \\
  '.join(parts)

def main(har_path, url_filter=None):
    with open(har_path) as f:
        har = json.load(f)

    entries = har['log']['entries']
    if url_filter:
        entries = [e for e in entries if url_filter in e['request']['url']]

    for i, entry in enumerate(entries):
        print(f"\n# Request {i+1}: {entry['request']['method']} {entry['request']['url']}")
        print(har_to_curl(entry))

if __name__ == '__main__':
    har_file = sys.argv[1]
    filter_url = sys.argv[2] if len(sys.argv) > 2 else None
    main(har_file, filter_url)

# Usage:
# python har_to_curl.py session.har
# python har_to_curl.py session.har api.example.com  # filter by URL
7

Sanitizing HAR Files Before Sharing

When sharing HAR files with support teams, always redact sensitive information first. Here is a script to remove auth tokens and session cookies:

jssanitize-har.js
const fs = require('fs');

function sanitizeHar(har) {
  const sensitiveHeaders = new Set([
    'authorization', 'cookie', 'set-cookie',
    'x-api-key', 'x-auth-token', 'x-session-id',
  ]);

  function redactHeaders(headers) {
    return headers.map(h => ({
      ...h,
      value: sensitiveHeaders.has(h.name.toLowerCase()) ? '[REDACTED]' : h.value,
    }));
  }

  return {
    ...har,
    log: {
      ...har.log,
      entries: har.log.entries.map(entry => ({
        ...entry,
        request: {
          ...entry.request,
          headers: redactHeaders(entry.request.headers || []),
          cookies: [], // Remove all cookies
        },
        response: {
          ...entry.response,
          headers: redactHeaders(entry.response.headers || []),
          cookies: [],
        },
      })),
    },
  };
}

const input = JSON.parse(fs.readFileSync('raw-session.har', 'utf8'));
const sanitized = sanitizeHar(input);
fs.writeFileSync('sanitized-session.har', JSON.stringify(sanitized, null, 2));
console.log('Sanitized HAR written to sanitized-session.har');

Use the HAR sanitizer before any support ticket

Tools like Google's HAR Sanitizer (available online) can automatically detect and redact common sensitive patterns. Always run your HAR through a sanitizer before attaching it to a support ticket or sharing in a public forum.
8

HAR File Structure Reference

jsonhar-structure.json
{
  "log": {
    "version": "1.2",
    "creator": { "name": "Chrome", "version": "120" },
    "entries": [
      {
        "startedDateTime": "2026-03-01T10:00:00.000Z",
        "time": 245.3,
        "request": {
          "method": "POST",
          "url": "https://api.example.com/login",
          "headers": [
            { "name": "Content-Type", "value": "application/json" },
            { "name": "Authorization", "value": "Bearer eyJhbGci..." }
          ],
          "cookies": [
            { "name": "session", "value": "abc123" }
          ],
          "postData": {
            "mimeType": "application/json",
            "text": "{"username":"alice"}"
          }
        },
        "response": {
          "status": 200,
          "statusText": "OK",
          "headers": [...],
          "content": {
            "mimeType": "application/json",
            "text": "{"token":"xyz"}"
          }
        },
        "timings": {
          "send": 0.5,
          "wait": 220.1,
          "receive": 24.7
        }
      }
    ]
  }
}

Frequently Asked Questions