> For the complete documentation index, see [llms.txt](https://docs.rulecube.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rulecube.com/v2.5/language-reference/compression.md).

# Compression

Collection of compression functions.

### Methods

#### gzip

```javascript
gzip(data: string)
```

Compresses a string using GZIP.

**Parameters**

&#x20;   **data&#x20;*****string***

&#x20;       The data to compress.

**Return type**

&#x20;   string

**Examples**

```javascript
// Compress a string using GZIP
Compression.gzip('Hello, world!')
```

#### gunzip

```javascript
gunzip(data: string)
```

Decompresses a string using GZIP.

**Parameters**

&#x20;   **data&#x20;*****string***

&#x20;       The data to decompress.

**Return type**

&#x20;   string

**Examples**

```javascript
// Decompress a string using gzip
Compression.gunzip('H4sIAAAAAAAA/8tIzcnJVyjPL8pJUQQAlK4JWgAAAA==')
```

#### unzip

```javascript
unzip(data: string)
```

Unzips a zip archive and returns the files within the archive. The data of each file is returned as a base64 string, since it is possible a file is binary (e.g. images, PDFs). To get the string contents you will need to decode it using `atob()` to get the original string contents.

**Parameters**

&#x20;   **data&#x20;*****string***

&#x20;       The zip archive data to unzip as a base64 string.

**Return type**

&#x20;   { files: Array<{ name: string, size: number, crc32: number, type: 'File' | 'Directory', dateLastModified: Date, data: string }> }

**Examples**

```javascript
// Unzip a zip archive
let directory = Compression.unzip('...base64 zip data...')
let fileContents = atob(directory.files[0].data)            // Decode base64 to string of the first file
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.rulecube.com/v2.5/language-reference/compression.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
