No description, website, or topics provided.
Branch: master
Clone or download
Latest commit 6b617fe Mar 18, 2017
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin Update to JSZip 2.1.1 Feb 16, 2014
lib Update to JSZip 2.1.1 Feb 16, 2014
test Update to JSZip 2.1.1 Feb 16, 2014
.gitignore gitignore Apr 29, 2012
Makefile move uglifier from Makefile to bin/packer Mar 10, 2013 docs: add complete example, use markdown syntax Jan 13, 2017
package.json add license property to package.json Feb 7, 2016


node-zip - Zip/Unzip files ported from JSZip


npm install node-zip


Complete example, zip multiple files

var fs = require('fs');
var path = require('path');

// The zip library needs to be instantiated:
var zip = new require('node-zip')();

// You can add multiple files by performing subsequent calls to zip.file();
// the first argument is how you want the file to be named inside your zip,
// the second is the actual data:
zip.file('file1.txt', fs.readFileSync(path.join(__dirname, 'file1.txt')));
zip.file('file2.txt', fs.readFileSync(path.join(__dirname, 'file2.txt')));

var data = zip.generate({ base64:false, compression: 'DEFLATE' });

// it's important to use *binary* encode
fs.writeFileSync('', data, 'binary');

You can also load directly:

var zip = new JSZip(data, options)

Zip text into file:

var zip = new require('node-zip')();

zip.file('test.file', 'hello there');
var data = zip.generate({base64:false,compression:'DEFLATE'});
console.log(data); // ugly data


var zip = new require('node-zip')(data, {base64: false, checkCRC32: true});
console.log(zip.files['test.file']); // hello there

Write to a file (IMPORTANT: use binary encode, thanks to @Acek)

var fs = require("fs");
zip.file('test.txt', 'hello there');
var data = zip.generate({base64:false,compression:'DEFLATE'});
fs.writeFileSync('', data, 'binary');


npm install -g jasmine-node
jasmine-node test


node-zip uses JSZip, please refer to their website for further information:


David Duponchel @dduponchel

Feel free to send your pull requests and contribute to this project