Skip to content

split / export / dedup / add-headers / clone ​

These commands operate on an existing HAR file (--input), enabling post-generation processing.

Post-processing pipeline ​

mermaid
flowchart LR
    In["out.har"] --> Split["split"]
    In --> Dedup["dedup"]
    In --> Add["add-headers"]
    In --> Clo["clone"]
    In --> Exp["export"]
    Split --> P1["parts/*.har"]
    Dedup --> P2["dedup.har"]
    Add --> P3["modified.har"]
    Clo --> P4["copy.har"]
    Exp --> Out["curl/wget/..."]

    style In fill:#fff3e0
    style Out fill:#e8f5e9

split — split HAR by dimension ​

bash
request-mock split --input out.har --by method -o parts/
request-mock split --input out.har --by size --size 10 -o parts/
request-mock split --input out.har --by time --interval 1m -o parts/

Dimensions ​

DimensionGroups byKey example
pageHAR page (pageref)page_0
domainURL hostapi.example.com
statusResponse status code200, 404
methodHTTP methodGET, POST
sizeEntry count per group (configurable --size)method-0, method-1
timeStartedDateTime bucket (--interval)2026-07-05T10:00

Split flow ​

mermaid
flowchart TB
    H["*har.Har (N entries)"] --> Mode{"--by"}
    Mode -->|page| F1["group by entry.Pageref"]
    Mode -->|domain| F2["group by URL host"]
    Mode -->|status| F3["group by response.status"]
    Mode -->|method| F4["group by request.method"]
    Mode -->|size| F5["chunk by --size"]
    Mode -->|time| F6["bucket by --interval"]
    F1 --> Map["map[string]*har.Har"]
    F2 --> Map
    F3 --> Map
    F4 --> Map
    F5 --> Map
    F6 --> Map
    Map --> Out["parts/*.har OR summary envelope"]

    style Map fill:#e8f5e9

When -o <dir> is set, each group is written to <dir>/<mode>-<key>.har. Without -o, a summary envelope is printed to stdout listing keys and entry counts.

export — convert HAR to another format ​

bash
request-mock export --input out.har -f curl --raw
request-mock export --input out.har -f postman -o collection.json

Useful for: taking a generated HAR and re-exporting to whichever format you need without regenerating.

dedup — remove duplicate entries ​

bash
request-mock dedup --input out.har -o dedup.har

Groups entries by URL+Method+Status, keeps the first of each group, and reports the duplicate groups:

json
{"ok":true,"count":3,"removed":2,"groups":[{"key":"GET|https://...|200","count":3,"indices":[0,1,2]}]}

add-headers — batch add headers ​

bash
request-mock add-headers --input out.har -H 'X-Trace-Id: abc-123' -H 'X-Env: staging' --target request -o modified.har
request-mock add-headers --input out.har -H 'X-Frame-Options: DENY' --target response

--target must be request or response. Headers are added to every entry.

clone — deep-copy ​

bash
request-mock clone --input out.har -o copy.har

Produces a deep copy via mock.CloneHar. Useful before destructive pipeline steps.

Released under the MIT License.