shrink-har v1.0.3
shrink-har

Shrink-HAR is a command line utility that reduces the size of saved HTTP Archive files 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
HARfiles and report on potential savings. - Optionally backup existing
HARfiles to aZIPfile before shrinking them. - Shrink
HARfiles by stripping them, permanently, of all the response bodies.
Installation
Install globally via npm using:
npm install -g shrink-harUsage
By default, running shrink-har without any options will result in an analysis of *.har files in the current directory:
shrink-harThis behaviour can be modified via the following options.
--file
--file <filespec>
Specifies a filename or, using wildcards, a file specification.
Default: *.har
e.g.
shrink-har --file www.amazon.co.uk.har-or-
shrink-har --file *amazon*.har--directory
--directory <path>
Specifies the target directory.
Default: . (current working directory)
e.g.
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.
shrink-har --commit--yes
--yes
Automatically answer "yes" to confirmation prompts. Use with --commit.
Default: false
e.g.
shrink-har --commit --yes--backup
--backup
Backup all target .har files into a single .zip file before committing changes.
Default: false
e.g.
shrink-har --commit --backup--verbose
--verbose
Enables verbose output.
Default: false
e.g.
shrink-har --verbose--debug
--debug
Enables debugging output.
Default: false
e.g.
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:
shrink-har
Verbose output of current directory's analysis
Analyse *.har in the current directory displaying verbose output
shrink-har --verbose
Shrink all HAR files in current directory (interactive)
Shrink *.har in the current directory, with a confirmation prompt
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
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
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
shrink-har --directory ./Downloads/HARFiles/ --commit --yes
Change Log
The Change Log can be found here