loadAsync(data [, options])

Description : Read an existing zip and merge the data in the current JSZip object at the current folder level. This technique has some limitations, see here.


name type description
data String/Array of bytes/ArrayBuffer/Uint8Array/Buffer/Blob/Promise the zip file
options object the options to load the zip file

Content of options :

name type default description
options.base64 boolean false set to true if the data is base64 encoded, false for binary.
options.checkCRC32 boolean false set to true if the read data should be checked against its CRC32.
options.optimizedBinaryString boolean false set to true if (and only if) the input is a string and has already been prepared with a 0xFF mask.
options.createFolders boolean false set to true to create folders in the file path automatically. Leaving it false will result in only virtual folders (i.e. folders that merely represent part of the file path) being created.
options.decodeFileName function decode from UTF-8 the function to decode the file name / comment.

You shouldn’t update the data given to this method : it is kept as it so any update will impact the stored data.

Zip features supported by this method :

  • Compression (DEFLATE supported)
  • zip with data descriptor
  • ZIP64
  • UTF8 in file name, UTF8 in file content

Zip features not (yet) supported :

  • password protected zip
  • multi-volume zip

About decodeFileName :

A zip file has a flag to say if the filename and comment are encoded with UTF-8. If it’s not set, JSZip has no way to know the encoding used. It usually is the default encoding of the operating system.

The function takes the bytes array (Uint8Array or Array) and returns the decoded string.

Returns : A Promise with the updated zip object. The promise can fail if the loaded data is not valid zip data or if it uses features (multi volume, password protected, etc).


var zip = new JSZip();
require("fs").readFile("hello.zip", function (err, data) {
  if (err) throw err;
  var zip = new JSZip();

Using sub folders :

var zip = new JSZip();
// the content of data will be loaded in subfolder/

Using a custom charset :

// using iconv-lite for example
var iconv = require('iconv-lite');

zip.loadAsync(content, {
    decodeFileName: function (bytes) {
        return iconv.decode(bytes, 'your-encoding');