lz-string

Fast, dependency-free LZ-based string compression for JavaScript and TypeScript

Library
npm
v1.5.0
4,425stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
49/100Fair
Development Activity0
Maintenance20
Community76
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
69/100Good
Architecture65
Code Quality68
Innovation62
Learning Curve80

lz-string is a lightweight JavaScript/TypeScript implementation of an LZ-based compression algorithm purpose-built for compressing strings, not files. Version 2 ships as a joint CommonJS/ESM package with a bundled CLI, and offers multiple output encodings (base64, UTF-16, URI-component-safe, raw, Uint8Array) so compressed data can be safely stored wherever plain strings are expected.

It is one of the most widely used compression utilities in the JS ecosystem for shrinking data before writing to localStorage, embedding in URLs, or shipping over constrained network payloads, and has been ported to numerous other languages for cross-platform compatibility.

What You Get

  • Core compress()/decompress() functions for raw string compression
  • Encoding-specific helpers: base64, UTF-16, URI-component-safe, and Uint8Array output formats
  • A CLI (lz-string binary) for compressing/decompressing files from the command line
  • Dual CommonJS/ESM build output with TypeScript type definitions
  • Zero runtime dependencies, keeping bundle size minimal for browser use

Common Use Cases

  • Compressing large JSON or state blobs before storing them in browser localStorage/sessionStorage
  • Shrinking data to fit within URL length limits by compressing to a URI-component-safe encoding
  • Reducing payload size for data embedded in query strings or QR codes
  • Cross-language data interchange using one of the library’s many community ports (Java, Python, Go, etc.)

Under The Hood

Architecture The library centers on a shared LZ78-style compression core split across _compress.ts and _decompress.ts, with index.ts acting as a thin dispatcher that wires the core engine to encoding-specific wrappers (base64, UTF-16, URI-component, raw, Uint8Array) found in their own subdirectories; a separate cli.ts built on commander exposes the same engine as a standalone binary for file-based compression, and node.ts provides Node-specific entry adjustments. Tech Stack Written in TypeScript, built with Vite (vite.config.mts for the library, a second config for the CLI) producing dual CJS/ESM output plus .d.ts type declarations via vite-plugin-dts; the package has zero runtime dependencies, keeping the compiled bundle minimal for browser consumption. Code Quality Tests live under src/__tests__ with accompanying __snapshots__, run via Vitest with coverage and benchmark modes (test:bench, test:coverage) configured in package.json; the recent v2 rewrite (joint CJS/ESM layout) suggests active modernization even though day-to-day commit activity is currently low. API Design The API is deliberately minimal — a handful of compress*/decompress* function pairs named after their target encoding — which makes the library trivial to adopt with almost no boilerplate, though the multiple encoding variants (base64 vs UTF-16 vs raw) require the caller to understand which encoding matches their storage target to avoid corruption.

Used by 8 apps in this directory

TypeScript
88%
Other

AFFiNE

Productivity · Project Management · Note Taking

71,668

Write, draw, and plan in one infinite canvas — the open-source alternative to Notion and Miro that keeps your data yours.

View details
91
Repo Health
87
Technical
68
Dependency
Built with
TypeScript88%
Updated today
TypeScript
59%
Other

agenta

Developer Tools · Devops · AI Development

4,489

The open-source LLMOps platform unifying prompt engineering, evaluation, and observability for teams building reliable LLM applications.

View details
91
Repo Health
77
Technical
67
Dependency
Built with
TypeScript59%
Python39%
Updated today
TypeScript
98%
MIT

GraphQL Hive

Developer Tools · Devops · Monitoring

485

Open-source GraphQL schema registry and observability platform with breaking change detection, federation support, and CI/CD integration for teams of any size.

View details
90
Repo Health
81
Technical
70
Dependency
Built with
TypeScript98%
Updated today
TypeScript
97%
Other

Kibana

Analytics · Monitoring

21,251

Your open source window into the Elastic Stack — query, visualize, and act on data stored in Elasticsearch with real-time dashboards, AI-assisted search, and automated alerting.

View details
98
Repo Health
87
Technical
68
Dependency
Built with
TypeScript97%
Updated today
Python
61%
Apache 2.0

marimo

Developer Tools · Data Engineering

22,393

A reactive Python notebook that eliminates hidden state, runs reproducibly, and deploys as a web app or script — stored as pure Python, built for the AI era.

View details
90
Repo Health
91
Technical
66
Dependency
Built with
Python61%
TypeScript37%
Updated today
HTML
32%

OpenPanel

Hosting Control Panel · Devops

733

Docker-powered web hosting control panel that gives every user a fully isolated environment with dedicated web server, database, and networking — VPS-grade security on shared hardware.

View details
81
Repo Health
75
Technical
63
Dependency
Built with
HTML32%
Go31%
TypeScript28%
Updated today
TypeScript
93%
Apache 2.0

Openship

Devops · Hosting Control Panel

11,078

Openship is an open-source, self-hostable deployment platform that points at a repo and builds, ships, routes, and TLS-terminates the app — driven from a desktop app, web dashboard, or CLI.

View details
82
Repo Health
85
Technical
65
Dependency
Built with
TypeScript93%
Updated today
TypeScript
92%
AGPL 3.0

RSSHub

Automation · Social Media

45,802

Turn any website into an RSS feed — social media, streaming platforms, and niche sites all become subscribable in seconds.

View details
83
Repo Health
82
Technical
74
Dependency
Built with
TypeScript92%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search