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

@larrym/lz-string

v1.0.0

Published

LZ-based compression algorithm for JavaScript with ESM support

Readme

@larrym/lz-string

LZ-based compression algorithm for JavaScript with full ESM (ECMAScript Modules) support.

This package is a modern ESM-compatible fork of the original lz-string library by pieroxy, providing the same powerful compression capabilities with improved module support.

Features

  • Full ESM (ECMAScript Modules) support
  • CommonJS compatibility for legacy projects
  • TypeScript type definitions included
  • Zero dependencies
  • Works in Node.js and browsers
  • Multiple compression formats (Base64, UTF-16, URI-safe, Uint8Array)

Requirements

  • Node.js >= 18.0.0

Installation

npm install @larrym/lz-string

Usage

ESM (ECMAScript Modules)

import { compress, decompress, compressToBase64, decompressFromBase64 } from '@larrym/lz-string';

// Basic compression
const compressed = compress('Hello, World!');
const decompressed = decompress(compressed);

// Base64 compression
const compressedB64 = compressToBase64('Hello, World!');
const decompressedB64 = decompressFromBase64(compressedB64);

CommonJS

const { compress, decompress } = require('@larrym/lz-string');

const compressed = compress('Hello, World!');
const decompressed = decompress(compressed);

Default Import

import LZString from '@larrym/lz-string';

const compressed = LZString.compress('Hello, World!');
const decompressed = LZString.decompress(compressed);

API

compress(input: string): string

Compresses a string and returns the compressed string.

decompress(compressed: string): string | null

Decompresses a string compressed with compress().

compressToBase64(input: string): string

Compresses a string to a Base64 encoded string.

decompressFromBase64(input: string): string | null

Decompresses a Base64 encoded string.

compressToUTF16(input: string): string

Compresses a string to UTF-16 format.

decompressFromUTF16(compressed: string): string | null

Decompresses a UTF-16 compressed string.

compressToEncodedURIComponent(input: string): string

Compresses a string to a URI-safe format.

decompressFromEncodedURIComponent(input: string): string | null

Decompresses a URI-safe compressed string.

compressToUint8Array(input: string): Uint8Array

Compresses a string to a Uint8Array.

decompressFromUint8Array(compressed: Uint8Array): string | null

Decompresses a Uint8Array.

Browser Usage

You can use this package directly in modern browsers with ESM support:

<script type="module">
  import { compress, decompress } from 'https://unpkg.com/@larrym/[email protected]/src/lz-string.js';

  const compressed = compress('Hello, World!');
  console.log(compressed);

  const decompressed = decompress(compressed);
  console.log(decompressed);
</script>

Differences from Original lz-string

  • Native ESM support with proper package.json exports
  • Maintained TypeScript definitions
  • Modern JavaScript syntax (const/let instead of var)
  • Simplified module structure

License

MIT License - see LICENSE file for details

Original work Copyright (c) 2013 pieroxy Modified work Copyright (c) 2025 Larry Motalavigne

Credits

This package is based on the original lz-string library by pieroxy.