Skip to content
This repository

zip utility implemented with JavaScript

tag: 2.2.0

Fetching latest commit…

Cannot retrieve the latest commit at this time


It's a utility of zlib, gzip and zip format binary data.

API Reference

suported browser

chrome, firefox, IE10.



decompress compressed swf file:

    jz.utils.load('compressed.swf', function(swf){
      var header = new Uint8Array(swf, 0, 8);
      var decompressedData = jz.zlib.decompress(new Uint8Array(swf, 8));


compress and download:

    var text = 'aaaaaabbbbbbbbbbbccccccccc';
    var gzbuff = jz.gz.compress(jz.utils.toBytes(text));
    var URL = window.URL || window.webkitURL;
    location.href = URL.createObjectURL(new Blob([new Uint8Array(gzbuff)]));



    var files = [
      {name: "foo", dir: [ // folder
        {name: "hello.txt", buffer: "Hello World!"}, // string
        {name: "bar.js", buffer: buffer}, // ArrayBuffer
        {name: "hoge.mp3", url: "audiodata/hoge.mp3"} // xhr
      files: files,
      level: 5, // compress level
      complete: function(buffer){ // buffer is ArrayBuffer
      error: function(err){

    // or{
      files: files,
      level: 5

    //set compress level each files.
    var files = [
      {name: "mimetype", buffer: "application/epub+zip", level: 0}, //string
      {name: "META-INF", dir: [ //folder
        {name: "container.xml", buffer: buffer, level: 0}, //ArrayBuffer
      {name: "package.opf", url: "package.opf", level: 6},
      {name: "foo.xhtml", url: "foo.xhtml", level: 9} //xhr
      files: files,
      complete: function(buffer){

      buffer: buffer,
      encoding: 'cp932', //encoding of filenames.
      complete: function(reader) {
        // get file pathes.
        // file is read lazy.
        reader.getFileAsText(reader.getFileNames[0], function(result){
      error: function(err) {}

    // or{
      buffer: buffer,
      encoding: 'cp932'

    // you can skip to set the encoding.

custom build

You can use the to build jsziptools.

$ #see help
$ ./ -h
usage: [-h] [-C COMPILER_PATH] [-m MODULES] [-o OUTPUT_PATH]
                [-c CONF_FILE_PATH]

optional arguments:
  -h, --help         show this help message and exit
  -C COMPILER_PATH   Set a Closure Compiler path.
  -m MODULES         Set module names you want to use.
  -o OUTPUT_PATH     Set a output file path.
  -c CONF_FILE_PATH  Set a configuration file path.
$ #select modules
$ ./ -m gz.decompress zlib.decompress -o build/gz_zlib_decomp.min.js

module list:

  • gz.compress
  • gz.decompress
  • gz (gz.compressandgz.decompess)
  • zlib.compress
  • zlib.decompress
  • zlib (zlib.compressandzlib.decompress)
  • zip.pack
  • zip.unpack
  • zip (zip.packandzip.unpack)

You also can write a configuration file that is written in json.

Example of a configuration file:

    "compiler": "./compiler.jar",
    "output": "./build/jsziptools.unzip.min.js",
    "files": [


$ ./ -c buildconf.json
Something went wrong with that request. Please try again.