# redzip

> work with files inside archives like with regular files

Latest version **4.6.1** (published 2026-03-17) · MIT license · 1.2K weekly downloads

## Install

```sh
npm install redzip
pnpm add redzip
yarn add redzip
bun add redzip
```

## Health

**Score 60/100 (C)** — status: active.

Positive: esm support; no vulnerabilities.

Warnings: no types.

## Facts

| | |
|---|---|
| Version | 4.6.1 |
| Published | 2026-03-17 |
| First published | 2021-01-06 |
| Weekly downloads | 1.2K |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=22 |
| Dependencies | 13 |
| Unpacked size | 32 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Maintainers | coderaiser |
| Keywords | directory, read, readdir, readify, file, folder, zip |

## Links

- npm: https://www.npmjs.com/package/redzip
- Repository: https://github.com/coderaiser/redzip
- Homepage: http://github.com/coderaiser/redzip
- Issues: https://github.com/coderaiser/redzip/issues
- npm.io page: https://npm.io/package/redzip

## Dependencies (13)

- [once](https://npm.io/package/once.md) ^1.4.0
- [yazl](https://npm.io/package/yazl.md) ^3.3.1
- [yauzl](https://npm.io/package/yauzl.md) ^3.1.2
- [pipe-io](https://npm.io/package/pipe-io.md) ^4.0.1
- [readify](https://npm.io/package/readify.md) ^11.0.0
- [readzip](https://npm.io/package/readzip.md) ^3.0.0
- [trammel](https://npm.io/package/trammel.md) ^6.0.0
- [totalist](https://npm.io/package/totalist.md) ^3.0.1
- [wraptile](https://npm.io/package/wraptile.md) ^3.0.0
- [format-io](https://npm.io/package/format-io.md) ^2.0.0
- [try-to-catch](https://npm.io/package/try-to-catch.md) ^4.0.4
- [@cloudcmd/sortify](https://npm.io/package/@cloudcmd/sortify.md) ^2.0.1
- [@cloudcmd/formatify](https://npm.io/package/@cloudcmd/formatify.md) ^3.0.0

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads
- [restbox](https://npm.io/package/restbox.md) — 328 weekly downloads

## Recent versions

- 4.6.1 (latest) — 2026-03-17
- 4.6.0 — 2026-02-28
- 4.5.1 — 2026-02-26
- 4.5.0 — 2026-02-26
- 4.4.0 — 2026-02-26
- 4.3.0 — 2026-02-25
- 4.2.0 — 2026-02-24
- 4.1.0 — 2026-02-21
- 4.0.1 — 2026-02-12
- 4.0.0 — 2026-01-31
- 3.0.5 — 2024-08-16
- 3.0.4 — 2024-08-16
- 3.0.3 — 2024-03-29
- 3.0.2 — 2024-03-18
- 3.0.1 — 2023-08-10
- … 43 more at https://npm.io/package/redzip/versions

## README

# Redzip [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]

[NPMIMGURL]: https://img.shields.io/npm/v/redzip.svg?style=flat
[BuildStatusURL]: https://github.com/coderaiser/redzip/actions
[BuildStatusIMGURL]: https://github.com/coderaiser/redzip/workflows/CI/badge.svg
[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat
[NPMURL]: https://npmjs.org/package/redzip "npm"
[BuildStatusURL]: https://travis-ci.org/coderaiser/redzip "Build Status"
[LicenseURL]: https://tldrlegal.com/license/mit-license "MIT License"
[CoverageURL]: https://coveralls.io/github/coderaiser/redzip?branch=master
[CoverageIMGURL]: https://coveralls.io/repos/coderaiser/redzip/badge.svg?branch=master&service=github

Work with zip archives as it is regular files and directories.

## Install

```
npm i redzip
```

## API

### read(path[, options])

- **path** - `string`
- **options** - `object` can contain:
  - `sort` - sort by: name, size, date
  - `order` - "asc" or "desc" for ascending and descending order (default: "asc")
  - `type` - when "raw" returns not formatted result
  - `root` - root directory to cut from result

#### Example

```js
import * as redzip from 'redzip';

const sort = 'size';
const order = 'desc';
const type = 'raw';
const dirPath = '/home/coderaiser/hello.zip/hello/';
const path = '/home/coderaiser/hello.zip/hello.txt';

const dirStream = await redzip.read(dirPath, {
    type,
    sort,
    order,
});

console.log(dirStream.type);
// outputs
'directory';

console.log(dirStream.contentLength);
// outputs
280;

dirStream.pipe(process.stdout);
// outputs
({
    path: '/',
    files: [{
        name: 'redzip.js',
        size: 4735,
        date: 1_377_248_899_000,
        owner: 0,
        mode: 0,
    }, {
        name: 'readify.js',
        size: 3735,
        date: 1_377_248_899_000,
        owner: 0,
        mode: 0,
    }],
});

dirStream.files;
// returns
[{
    name: 'redzip.js',
    size: 4735,
    date: 1_377_248_899_000,
    owner: 0,
    mode: 0,
}, {
    name: 'readify.js',
    size: 3735,
    date: 1_377_248_899_000,
    owner: 0,
    mode: 0,
}];

dirStream.path;
// returns
'/';

const fileStream = await redzip.read(path);
console.log(fileStream.type);
// outputs
'file';

fileStream.pipe(process.stdout);
// outputs
'hello';

console.log(fileStream.contentLength);
// outputs
6;
```

### readSize(path[, options])

- **path** - `string`
- **options** - `object` can contain:
  - `type` - when "raw" returns not formatted result

```js
const fileStream = readSize('/hello/world.zip/readme.md');

fileStream.pipe(process.stdout);
// outputs
'10kb';

fileStream.contentLength; // 4
```

### readStat(path[, options])

- **path** - `string`

```js
const stat = readStat('/hello/world.zip/readme.md');

// returns
({
    date: '2021-01-18T22:00:00.000Z',
    mode: 1_107_099_648,
    name: 'readme.md',
    owner: 0,
    size: 0,
    type: 'file',
});
```

### write(path[, data], options)

When you need to save `string`, or `Buffer` use [Readable.from](https://nodejs.org/dist/latest-v17.x/docs/api/stream.html#streamreadablefromiterable-options).

- **path** - `string`
- **data** - `stream`
- **options** - `object` can contain:
  - `unzip` - unzip file content before writing
  - `mode` - set permissions mode (optional)
  - `date` - date of modication

#### Example

```js
import {Readable} from 'node:stream';
import {createGzip} from 'node:zlib';
import {write} from 'redzip';
import pullout from 'pullout';

const dirPath = '/home/coderaiser/hello.zip/hello/';
await write(dirPath);
// returns
'save: ok("hello")';

const path = '/home/coderaiser/hello.zip/hello.txt';
const writeStream = await write(path, Readable.from('hello'));

await pullout(writeStream);
// returns
'save: ok("hello")';

await pullout(await read(path));
// returns
'hello';

const zipStream = Readable
    .from('hello')
    .pipe(createGzip());

await write(path, zipStream, {
    unzip: true,
});
const readStream = await read(path);
await pullout(readStream);
// returns
'hello';
```

### remove(path)

- **path** - `string`

#### Example

```js
import {remove} from 'redzip';
import pullout from 'pullout';

const dirPath = '/home/coderaiser/hello.zip/hello/';
await remove(dirPath);

const path = '/home/coderaiser/hello.zip/hello.txt';
await remove(path);
```

### list(path)

- **path** - `string`

#### Example

```js
import {list} from 'redzip';

const dirPath = '/home/coderaiser/hello.zip/hello/';
await list(dirPath);
// returns
[
    '/Users/coderaiser/hello.zip/hello/world.txt',
];
```

## Related

- [readify](https://github.com/coderaiser/readify "readify") - read directory content with file attributes: size, date, owner, mode
- [readbox](https://github.com/coderaiser/readbox "readbox") - read file or directory from `dropbox`

## License

MIT

---
_Source: https://npm.io/package/redzip · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
