https://github.com/marksmurphy/shrink-har
HTTP Archive files can be large when they contain multiple response bodies. If this content is superfluous to your debugging needs then `shrink-har` allows you create smaller copies of .har files with the response body content stripped out.
https://github.com/marksmurphy/shrink-har
archive devtools har http https reduce shrink
Last synced: 3 months ago
JSON representation
HTTP Archive files can be large when they contain multiple response bodies. If this content is superfluous to your debugging needs then `shrink-har` allows you create smaller copies of .har files with the response body content stripped out.
- Host: GitHub
- URL: https://github.com/marksmurphy/shrink-har
- Owner: markSmurphy
- Created: 2022-05-20T09:37:54.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-06-22T03:30:41.000Z (11 months ago)
- Last Synced: 2025-01-24T20:33:25.991Z (4 months ago)
- Topics: archive, devtools, har, http, https, reduce, shrink
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/shrink-har
- Size: 422 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# shrink-har


[](https://www.codacy.com/gh/markSmurphy/shrink-har/dashboard?utm_source=github.com&utm_medium=referral&utm_content=markSmurphy/shrink-har&utm_campaign=Badge_Grade)

[](https://snyk.io/test/github/markSmurphy/shrink-har?targetFile=package.json)





**Shrink-HAR** is a command line utility that reduces the size of saved [HTTP Archive files](https://en.wikipedia.org/wiki/HAR_(file_format)) by removing the response body.
*Caution* This tool is destructive. If you're using `HAR` files to debug API responses, or any other payload, then this tool isn't for you. It is *only* useful if your debugging needs are limited to HTTP request/response headers thereby rendering the response bodies superfluous.
## Overview
HTTP Archive files can be large when they contain multiple response bodies. I wrote this tool when I needed to retain dozens of `HAR` files but was only interested in HTTP headers. The response bodies (images, CSS, Javascript, API JSON, etc) were superfluous to my needs but were the majority of the file sizes.
Shrink-HAR will:
* Analyse `HAR` files and report on potential savings.
* Optionally backup existing `HAR` files to a `ZIP` file before shrinking them.
* Shrink `HAR` files by stripping them, permanently, of all the response bodies.## Installation
Install globally via `npm` using:
```shell
npm install -g shrink-har
```## Usage
By default, running `shrink-har` without any options will result in an analysis of `*.har` files in the current directory:
```shell
shrink-har
```This behaviour can be modified via the following options.
### --file
`--file `
Specifies a filename or, using wildcards, a file specification.
Default: `*.har`
e.g.
```shell
shrink-har --file www.amazon.co.uk.har
```-or-
```shell
shrink-har --file *amazon*.har
```### --directory
`--directory `
Specifies the target directory.
Default: `.` (current working directory)
e.g.
```shell
shrink-har --directory ~/Downloads/
```### --commit
`--commit`
Commit changes to files. If absent only an analysis is performed. A confirmation prompt is also shown, which can be modified with `--yes`.
Default: `false`
e.g.
```shell
shrink-har --commit
```### --yes
`--yes`
Automatically answer "*yes*" to confirmation prompts. Use with `--commit`.
Default: `false`
e.g.
```shell
shrink-har --commit --yes
```### --backup
``--backup``
Backup all target `.har` files into a single `.zip` file before committing changes.
Default: `false`
e.g.
```shell
shrink-har --commit --backup
```### --verbose
`--verbose`
Enables verbose output.
Default: `false`
e.g.
```shell
shrink-har --verbose
```### --debug
`--debug`
Enables debugging output.
Default: `false`
e.g.
```shell
shrink-har --debug
```### --no-color
`--no-color`
Switches off colour output.
### --version
`--version`
Display version number.
### --help
`--help`
Displays help screen.
## Examples
### Analyse current directory
Analyse `*.har` in the current directory:
```shell
shrink-har
```
---
### Verbose output of current directory's analysis
Analyse `*.har` in the current directory displaying verbose output
```shell
shrink-har --verbose
```
---
### Shrink all HAR files in current directory (interactive)
Shrink `*.har` in the current directory, with a confirmation prompt
```shell
shrink-har --commit
```
---
### Backup and Shrink all HAR files in current directory (silent)
Shrink `*.har` in the current directory, with no prompts, after making a backup
```shell
shrink-har --commit --yes --backup
```
---
### Shrink specific file in specific directory (interactive)
Shrink the file `www.example.com.har` in `./Downloads` after a confirmation prompt
```shell
shrink-har --file www.example.com.har --directory ./Downloads --commit
```
---
### Shrink all HAR files in specific directory without backing up (silent)
Shrink `*.har` in `./Downloads/HARFiles/` without backing up and with no prompt
> Warning, this command permanently removes data silently
```shell
shrink-har --directory ./Downloads/HARFiles/ --commit --yes
```
## Change Log
The **Change Log** can be found [here](CHANGELOG.md)