Socket
Book a DemoInstallSign in
Socket

compress-kit

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

compress-kit

๐Ÿ”ฌ Reliable, Cross-Platform Compression & Decompression for Web, Node.js, Deno, and Bun

1.1.0
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source
banner

compress-kit

Reliable, Cross-Platform Compression & Decompression
for Web, Node.js, Deno, and Bun

License npm version npm downloads stars

About ๐Ÿ“–

compress-kit is a modern compression toolkit for Web, Node.js, Deno, and Bun.
It offers a simple, consistent API for compressing and decompressing strings or objects, automatically deciding when compression is beneficial, while ensuring lossless results and type safety.

Features ๐ŸŒŸ

  • ๐Ÿ“‰ Strong Compression โ€“ Achieves size reductions of ~30% to 90% on typical text and JSON data using the Deflate algorithm via pako.
  • ๐Ÿง  Smart Compression โ€“ Automatically detects whether to store data compressed or uncompressed for optimal efficiency.
  • ๐ŸŒ Cross-Platform โ€“ Works seamlessly in Web, Node.js, Deno, and Bun with no code changes.
  • ๐Ÿ” Lossless Algorithms โ€“ Ensures perfect reconstruction of the original data.
  • ๐Ÿงช Strict Validation & Result<T> Typing โ€“ Unified return type and robust input checks for predictable results.

Installation ๐Ÿ”ฅ

npm install compress-kit@latest

๐Ÿ’ก Works with npm, pnpm, yarn, bun, and deno. You can use it in dev dependencies since it's typically used only for local HTTPS.

Usage ๐Ÿช›

import { compress, compressObj, decompress, decompressObj } from 'compress-kit';

// Compressing data
const compressed = compress('The brown fox (๐ŸฆŠ) jumps over the lazy dog (๐Ÿถ).');
if (compressed.success === false) {
  throw new Error(`Compression failed: ${compressed.error}`);
}

// Decompressing data
const decompressed = decompress(compressed.result);
console.log(decompressed.result);

// Compressing an object
const compressedObj = compressObj({ name: 'John Doe', age: 30, city: 'New York' });
if (compressedObj.success === false) {
  throw new Error(`Compression object failed: ${compressedObj.error}`);
}

// Decompressing an object
const decompressedObj = decompressObj(compressedObj.result);
console.log(decompressedObj.result);

NOTE: The compressed data follow the following format: <base64url>.<0 or 1>.. The first part is the base64url encoded compressed data, and the second part indicates whether the data is compressed (1) or not (0). The package hands the regex

Credit ๐Ÿ’ช๐Ÿฝ

We want to thank Pako for the inflate and deflate algorithms used in this package.

Contributions ๐Ÿค

Want to contribute or suggest a feature?

  • Open an issue or feature request
  • Submit a PR to improve the packages or add new ones
  • Star โญ the repo if you like what you see

License ๐Ÿ“œ

This project is licensed under the MIT License.

Thank you!

FAQs

Package last updated on 21 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.