Skip to main content

Synopsis

Export captured network requests to HTTP Archive (HAR) 1.2 format for analysis, sharing, or import into other tools.
bdg network har [output-file] [options]

Description

The network har command exports all network requests from the current session (or from session.json if no active session) to HAR 1.2 format. HAR files can be imported into Chrome DevTools, HAR analyzers, performance tools, and other debugging utilities. If no output file is specified, generates a timestamped filename in ~/.bdg/capture-YYYY-MM-DD-HHMMSS.har. Supports filtering with the same DevTools DSL syntax as network list to export only relevant requests.

Arguments

output-file
string
Path to output HAR file. If not provided, generates timestamped filename in ~/.bdg/ directory.Examples:
  • capture.har - Save to current directory
  • /tmp/debug.har - Absolute path
  • ~/Desktop/session.har - Home directory

Options

--json
flag
Output result metadata in JSON format (file path, entry count, filter status).
--filter
string
Filter requests using DevTools DSL syntax before exporting. Same syntax as network list --filter.Examples:
  • status-code:>=400 - Export only failed requests
  • domain:api.* - Export only API requests
  • larger-than:100KB - Export only large responses
  • !resource-type:Image,Media - Exclude media files

Filter Syntax

The --filter option uses Chrome DevTools filter DSL. See network list for complete syntax reference. Quick Reference:
status-code:>=400              # Status codes with comparison
domain:api.*                   # Domain with wildcards  
method:POST                    # HTTP method
mime-type:application/json     # MIME type
resource-type:XHR,Fetch        # Resource types (comma-separated)
larger-than:1MB                # Size threshold (B, KB, MB, GB)
has-response-header:set-cookie # Header presence
is:from-cache                  # Cached responses
is:running                     # In-progress requests
scheme:https                   # URL scheme
!domain:cdn.*                  # Negation (exclude)

Output Format

Human-readable (default)

 Exported 45 requests to /Users/user/.bdg/capture-2026-03-05-143022.har
With filter applied:
 Exported 12 requests (filtered) to /tmp/api-errors.har

JSON Format

{
  "version": "1.2.3",
  "success": true,
  "data": {
    "file": "/Users/user/.bdg/capture-2026-03-05-143022.har",
    "entries": 45,
    "filtered": false
  }
}

HAR File Structure

Generated HAR files conform to HAR 1.2 specification:
{
  "log": {
    "version": "1.2",
    "creator": {
      "name": "bdg",
      "version": "1.2.3"
    },
    "entries": [
      {
        "startedDateTime": "2026-03-05T14:30:22.123Z",
        "time": 245,
        "request": {
          "method": "GET",
          "url": "https://example.com/api/users",
          "httpVersion": "HTTP/2",
          "headers": [...],
          "queryString": [...],
          "cookies": [...],
          "headersSize": -1,
          "bodySize": 0
        },
        "response": {
          "status": 200,
          "statusText": "OK",
          "httpVersion": "HTTP/2",
          "headers": [...],
          "cookies": [...],
          "content": {
            "size": 1234,
            "mimeType": "application/json"
          },
          "redirectURL": "",
          "headersSize": -1,
          "bodySize": 1234
        },
        "cache": {},
        "timings": {
          "send": 0,
          "wait": 245,
          "receive": 0
        }
      }
    ]
  }
}

Examples

Export all requests with auto-generated filename

bdg network har

Export to specific file

bdg network har debug-session.har

Export only failed requests

bdg network har errors.har --filter "status-code:>=400"

Export API requests only

bdg network har api-calls.har --filter "resource-type:XHR,Fetch"

Export excluding large media files

bdg network har lightweight.har --filter "!larger-than:500KB !resource-type:Image,Media"

Export from stopped session

# HAR export works from session.json after session is stopped
bdg stop
bdg network har final-session.har

Get export metadata as JSON

bdg network har capture.har --json

Export specific domain’s requests

bdg network har api-only.har --filter "domain:api.example.com"

Use Cases

Import into Chrome DevTools

  1. Export HAR file: bdg network har session.har
  2. Open Chrome DevTools (F12)
  3. Go to Network tab
  4. Right-click → “Import HAR file”
  5. Select your exported file

Share debugging session

# Export filtered session for sharing with team
bdg network har bug-reproduction.har --filter "domain:api.internal.*"

Performance analysis

# Export for analysis in performance tools
bdg network har perf-data.har
# Use with webpagetest.org, HAR Analyzer, etc.

Automated testing

# Export and validate in CI/CD
bdg network har test-run.har --filter "status-code:>=400"
if [ $? -eq 0 ]; then
  # Check if any errors were exported
  entries=$(jq '.log.entries | length' test-run.har)
  if [ $entries -gt 0 ]; then
    echo "Found $entries failed requests"
    exit 1
  fi
fi

Exit Codes

0
SUCCESS
HAR file exported successfully
81
INVALID_ARGUMENTS
Invalid filter syntax or malformed filter DSL
83
RESOURCE_NOT_FOUND
No active session and no session.json file found
101
CDP_CONNECTION_FAILURE
Failed to connect to daemon (for live session)
103
SESSION_FILE_ERROR
Failed to write HAR file (check permissions and disk space)

Tips

Offline Export: HAR export works from session.json even after stopping the session:
bdg stop
bdg network har archived-session.har
Filter Before Export: Use --filter to reduce HAR file size:
# Export only relevant requests instead of full session
bdg network har --filter "domain:api.* status-code:>=400"
Timestamped Backups: Without specifying output file, bdg creates timestamped files:
bdg network har  # Creates capture-2026-03-05-143022.har
bdg network har  # Creates capture-2026-03-05-143145.har (different timestamp)
HAR files may contain sensitive data (cookies, authorization headers, POST data). Review before sharing externally.

See Also

Build docs developers (and LLMs) love