lz-string

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

Library
npm
v1.5.0
4,437 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
49 /100 Fair
Development Activity 0
Maintenance 20
Community 76
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
69 /100 Good
Architecture 65
Code Quality 68
Innovation 62
Learning Curve 80

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 9 apps in this directory

TypeScript
82%
Other

AFFiNE

Collaboration · Note Taking · Productivity

73,040

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
67
Dependency
Built with
TypeScript 82%
Rust 11%
Updated 5 days ago
TypeScript
56%
Other

agenta

AI Development · Developer Tools · Devops

4,788

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
TypeScript 56%
Python 39%
Updated 5 days ago
TypeScript
99%
MIT

GraphQL Hive

Developer Tools · Devops · Monitoring

484

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
69
Dependency
Built with
TypeScript 99%
Updated 4 days ago
TypeScript
98%
Other

Kibana

Analytics · Monitoring

21,301

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
63
Dependency
Built with
TypeScript 98%
Updated 4 days ago
TypeScript
44%
Other

Magic

AI Agents · Automation · Low Code Platforms

5,043

Magic is an enterprise-grade open-source AI agent platform combining a generalist AI agent, workflow engine, IM, and collaborative office system for running an AI-powered digital workforce.

View details
70
Repo Health
79
Technical
65
Dependency
Built with
TypeScript 44%
PHP 32%
Updated 1 months ago
Python
62%
Apache 2.0

marimo

Data Engineering · Developer Tools

22,918

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
89
Repo Health
91
Technical
65
Dependency
Built with
Python 62%
TypeScript 37%
Updated 5 days ago
HTML
36%

OpenPanel

Devops · Hosting Control Panel

749

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
84
Repo Health
75
Technical
63
Dependency
Built with
HTML 36%
Go 32%
TypeScript 23%
Updated 5 days ago
TypeScript
94%
Apache 2.0

Openship

Devops · Hosting Control Panel

12,979

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
84
Repo Health
85
Technical
65
Dependency
Built with
TypeScript 94%
Updated 5 days ago
TypeScript
100%
AGPL 3.0

RSSHub

Automation · Social Media

46,339

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

View details
94
Repo Health
82
Technical
72
Dependency
Built with
TypeScript 100%
Updated 5 days ago

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