---
title: Capacitor Zip Plugin for Android & iOS
description: Capacitor plugin to zip and unzip files and directories with support for encryption. Available on Android and iOS.
tags:
  - Insiders
  - Android
  - iOS
search:
  boost: 2
faq: true
github_repo: capawesome-team/capacitor-plugins
---

# Capacitor Zip Plugin

Capacitor plugin to zip and unzip files and directories with support for encryption.

<div class="capawesome-z29o10a">
  <a href="https://cloud.capawesome.io/" target="_blank">
    <img alt="Deliver Live Updates to your Capacitor app with Capawesome Cloud" src="https://cloud.capawesome.io/assets/banners/cloud-build-and-deploy-capacitor-apps.png?t=1" />
  </a>
</div>

## Features

The Capacitor Zip plugin is one of the most complete file archiving solutions for Capacitor apps. Here are some of the key features:

- 🖥️ **Cross-platform**: Supports Android and iOS.
- 📁 **File Compression**: Zip and unzip single or multiple files.
- 🔑 **Encryption**: Encrypt and decrypt files.
- 🤝 **Compatibility**: Compatible with the [File Compressor](https://capawesome.io/docs/sdks/capacitor/file-compressor/) plugin.
- 📦 **CocoaPods & SPM**: Supports CocoaPods and Swift Package Manager for iOS.
- 🔁 **Up-to-date**: Always supports the latest Capacitor version.
- ⭐️ **Support**: Priority support from the Capawesome Team.
- ✨ **Handcrafted**: Built from the ground up with care and expertise, not forked or AI-generated.

Missing a feature? Just [open an issue](https://github.com/capawesome-team/capacitor-plugins/issues) and we'll add it for you!

## Use Cases

The Zip plugin is typically used whenever an app needs to work with zip archives, for example:

- **File uploads**: Bundle multiple files or an entire directory into a single zip archive before uploading it to a server.
- **Content downloads**: Unzip archives downloaded from a server, for example to make content available offline.
- **Data backups**: Compress app data into an archive that can be exported and restored later.
- **Sensitive data protection**: Encrypt archives with a password when zipping and decrypt them when unzipping.

## Compatibility

| Plugin Version | Capacitor Version | Status         |
| -------------- | ----------------- | -------------- |
| 8.x.x          | >=8.x.x           | Active support |
| 7.x.x          | 7.x.x             | Deprecated     |
| 6.x.x          | 6.x.x             | Deprecated     |

## Demo

A working example can be found [here](https://github.com/robingenz/capacitor-plugin-demo).

## Installation

This plugin is only available to [Capawesome Insiders](https://capawesome.io/insiders/). 
First, make sure you have the Capawesome npm registry set up.
You can do this by running the following commands:

```
npm config set @capawesome-team:registry https://npm.registry.capawesome.io
npm config set //npm.registry.capawesome.io/:_authToken <YOUR_LICENSE_KEY>
```

**Attention**: Replace `<YOUR_LICENSE_KEY>` with the license key you received from Polar. If you don't have a license key yet, you can get one by becoming a [Capawesome Insider](https://capawesome.io/insiders/).

Next, you can use our **AI-Assisted Setup** to install the plugin.
Add the [Capawesome Skills](https://github.com/capawesome-team/skills) to your AI tool using the following command:

```bash
npx skills add capawesome-team/skills --skill capacitor-plugins
```

Then use the following prompt:

```
Use the `capacitor-plugins` skill from `capawesome-team/skills` to install the `@capawesome-team/capacitor-zip` plugin in my project.
```

If you prefer **Manual Setup**, install the plugin by running the following commands and follow the platform-specific instructions below:

```bash
npm install @capawesome-team/capacitor-zip
npx cap sync
```

### Android 

#### Proguard

If you are using Proguard, you need to add the following rules to your `proguard-rules.pro` file:

```
-keep class io.capawesome.capacitorjs.plugins.** { *; }
```

#### Variables

If needed, you can define the following project variable in your app’s `variables.gradle` file to change the default version of the dependency:

- `$zip4jVersion` version of `net.lingala.zip4j:zip4j` (default: `2.11.5`)

This can be useful if you encounter dependency conflicts with other plugins in your project.

### iOS

#### Minimum Deployment Target

If you are using **Swift Package Manager**, make sure that your iOS deployment target is set to at least `16.0` in your Xcode project settings (usually in `ios/App/App.xcodeproj`):

```diff
-IPHONEOS_DEPLOYMENT_TARGET = 15.0
+IPHONEOS_DEPLOYMENT_TARGET = 16.0
```

If you are using **CocoaPods**, make sure that your iOS deployment target is set to at least `16.0` in your `Podfile`:

```ruby
platform :ios, '16.0'
```

## Configuration

No configuration required for this plugin.

## Usage

The following examples show how to create a zip archive and extract an existing one.

### Zip a file or directory

Create a zip archive from a source file or directory. You can optionally provide a `password` to encrypt the archive. Only available on Android and iOS:

```typescript
import { Zip } from '@capawesome-team/capacitor-zip';

const zip = async () => {
  await Zip.zip({
    source: 'file:///data/user/0/dev.robingenz.capacitor.plugindemo/cache/1714900095398',
    destination: 'file:///data/user/0/dev.robingenz.capacitor.plugindemo/cache/1714900095398.zip',
    password: 'secret',
  });
};
```

### Unzip an archive

Extract a zip archive into a destination directory. If the archive is encrypted, provide the `password` to decrypt it. Only available on Android and iOS:

```typescript
import { Zip } from '@capawesome-team/capacitor-zip';

const unzip = async () => {
  await Zip.unzip({
    source: 'file:///data/user/0/dev.robingenz.capacitor.plugindemo/cache/1714900095398.zip',
    destination: 'file:///data/user/0/dev.robingenz.capacitor.plugindemo/cache/1714900095398',
    password: 'secret',
  });
};
```

## API

<docgen-index>

* [`unzip(...)`](#unzip)
* [`zip(...)`](#zip)
* [Interfaces](#interfaces)

</docgen-index>

<docgen-api>
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->

### unzip(...)

```typescript
unzip(options: UnzipOptions) => Promise<void>
```

Unzip a file.

Only available on Android and iOS.

| Param         | Type                                                  |
| ------------- | ----------------------------------------------------- |
| **`options`** | <code><a href="#unzipoptions">UnzipOptions</a></code> |

**Since:** 6.0.0

--------------------


### zip(...)

```typescript
zip(options: ZipOptions) => Promise<void>
```

Zip a file or directory.

Only available on Android and iOS.

| Param         | Type                                              |
| ------------- | ------------------------------------------------- |
| **`options`** | <code><a href="#zipoptions">ZipOptions</a></code> |

**Since:** 6.0.0

--------------------


### Interfaces


#### UnzipOptions

| Prop              | Type                | Description                           | Since |
| ----------------- | ------------------- | ------------------------------------- | ----- |
| **`destination`** | <code>string</code> | The destination directory.            | 6.0.0 |
| **`password`**    | <code>string</code> | The password to decrypt the zip file. | 6.1.0 |
| **`source`**      | <code>string</code> | The source file to unzip.             | 6.0.0 |


#### ZipOptions

| Prop              | Type                | Description                           | Since |
| ----------------- | ------------------- | ------------------------------------- | ----- |
| **`destination`** | <code>string</code> | The destination file.                 | 6.0.0 |
| **`password`**    | <code>string</code> | The password to encrypt the zip file. | 6.1.0 |
| **`source`**      | <code>string</code> | The source file or directory to zip.  | 6.0.0 |

</docgen-api>

## FAQ

### Can I create password-protected zip archives?

Yes. Pass the `password` option to the `zip(...)` method to encrypt the archive and pass the same option to the `unzip(...)` method to decrypt it. See the [usage examples](#usage) above.

### Can I zip an entire directory?

Yes. The `source` option of the `zip(...)` method accepts either a single file or a directory. When unzipping, the archive is extracted into the directory specified by the `destination` option.

### Does this plugin work on the Web?

No, the `zip(...)` and `unzip(...)` methods are only available on Android and iOS, as documented in the [API](#api) section.

### How is this plugin different from the File Compressor plugin?

The [File Compressor](https://capawesome.io/docs/sdks/capacitor/file-compressor/) plugin reduces the file size of individual image files such as PNG, JPEG, and WebP. The Zip plugin, on the other hand, bundles one or more files or directories into a zip archive and extracts them again. Both plugins are compatible and can be used together, for example to compress images before zipping them.

### Can I use this plugin with Ionic, React, Vue or Angular?

Yes, the plugin is framework-agnostic. It works in any Capacitor app regardless of the web framework, including Ionic with Angular, React, or Vue, as well as plain JavaScript projects.

## Related Plugins

- [File Compressor](https://capawesome.io/docs/sdks/capacitor/file-compressor/): Compress image files such as PNG, JPEG, and WebP.
- [File Opener](https://capawesome.io/docs/sdks/capacitor/file-opener/): Open a file with the default application.
- [File Picker](https://capawesome.io/docs/sdks/capacitor/file-picker/): Let the user select a file, directory, image, or video from the device.
- [Share Target](https://capawesome.io/docs/sdks/capacitor/share-target/): Receive files shared from other apps.

## Newsletter

Stay up to date with the latest news and updates about the Capawesome, Capacitor, and Ionic ecosystem by subscribing to our [Capawesome Newsletter](https://cloud.capawesome.io/newsletter/).

## Changelog

See [CHANGELOG.md](https://github.com/capawesome-team/capacitor-plugins/blob/main/packages/zip/CHANGELOG.md).

## Breaking Changes

See [BREAKING.md](https://github.com/capawesome-team/capacitor-plugins/blob/main/packages/zip/BREAKING.md).

## License

See [LICENSE](https://github.com/capawesome-team/capacitor-plugins/blob/main/packages/zip/LICENSE).
