npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

lz-utils

v2.1.1

Published

Utils for string compression and decompression with multiple strategies for Node.js and browser

Readme

lz-utils - Utils for string compression

Features

  • Zero runtime dependencies
  • Multiple compression strategies for different environments
  • ESM and CommonJS support
  • TypeScript type definitions included
  • Browser bundle (IIFE) included

API

| Method | Platform | Sync/Async | Algorithm | Minified | |:---|:---|:---|:---|:---| | deflateSync(str) | Node.js | Sync | Native zlib | 0.13 KB | | deflate(str) | Node.js | Async | Native zlib | 0.17 KB | | inflateSync(str) | Browser | Sync | tiny-inflate | 3.15 KB | | inflate(str) | Browser | Async (Worker) | tiny-inflate | 3.60 KB | | compress(str) | Both | Sync | lz-string | 1.71 KB | | decompress(str) | Both | Sync | lz-string | 1.59 KB | | createScriptLoader(str) | Node.js | Sync | zlib + loader template | 4.03 KB |

  • deflateSync / deflate - Compress raw string and encode in base64 (Node.js only, highest performance)
  • inflateSync / inflate - Decompress base64 string to raw string (Browser only, inflate uses Web Worker for multi-thread decompression)
  • compress / decompress - LZ-string based compression/decompression in base64 (works on both browser and Node.js)
  • createScriptLoader - Create a self-contained HTML script that decompresses and executes the given string in browser

Install

npm install lz-utils

Usage

Node.js - Compress with deflate (recommended)

const { deflateSync, deflate } = require('lz-utils');

const raw = "this is string";

// Synchronous
const compressed = deflateSync(raw);

// Asynchronous
const compressed = await deflate(raw);

Browser - Decompress with inflate

import { inflateSync, inflate } from 'lz-utils/inflate-sync';
// or
import { inflate } from 'lz-utils/inflate';

// Synchronous
const raw = inflateSync(compressed);

// Asynchronous (Web Worker)
const raw = await inflate(compressed);

Cross-platform - LZ-string compress/decompress

import { compress, decompress } from 'lz-utils';

const raw = "this is string";
const compressed = compress(raw);
const decompressed = decompress(compressed);

Create script loader

const { createScriptLoader } = require('lz-utils');

// Creates a self-contained HTML script that will decompress and execute in browser
const script = createScriptLoader('console.log("hello")');

Subpath imports

Each function can be imported individually to minimize bundle size:

import compress from 'lz-utils/compress';
import decompress from 'lz-utils/decompress';
import deflate from 'lz-utils/deflate';
import deflateSync from 'lz-utils/deflate-sync';
import inflate from 'lz-utils/inflate';
import inflateSync from 'lz-utils/inflate-sync';
import createScriptLoader from 'lz-utils/create-script-loader';

Examples

Why lz-utils?

lz-utils is designed for a specific workflow: generating self-contained HTML reports.

  • Goal - Generate HTML reports that are as fast to produce as possible and as small in file size as possible.
  • How it works - Report data is compressed on the server (Node.js) and bundled into a single HTML file. When the user opens the file in the browser, the data is self-decompressed and rendered on the fly. This is why deflate runs on Node.js and inflate runs in the browser.
  • Why base64? - The compressed output is binary data, which cannot be safely embedded in JavaScript (due to encoding and CORS issues). Converting it to base64 produces a plain JS string that can be reliably stored in JSON and embedded in HTML without any escaping problems.

String Compression Benchmark

Links

Changelog