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
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
How to Export a HAR File from Chrome
Open Chrome DevTools
Press F12 (or Cmd+Option+I on Mac) to open DevTools. Navigate to the Network tab.
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.
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.
Verify the export
Open the .har file in a text editor. You should see JSON starting with {"log": {"version": "1.2", "creator": {...}, "entries": [...]}}.
How to Export HAR from Firefox and Safari
| Item | Firefox | Safari |
|---|---|---|
| Open DevTools | F12 or Ctrl+Shift+I | Cmd+Option+I (enable Dev menu first) |
| Tab to use | Network tab | Network tab |
| Export button | Gear icon → Save All as HAR | Export button (down arrow icon) |
| File format | .har (JSON) | .har (JSON) |
| Response bodies | Included | May require "Record Network Content" enabled |
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
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:
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));
});Method 3: Filter and Convert with Python
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 URLSanitizing 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:
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
HAR File Structure Reference
{
"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
}
}
]
}
}