Projects

lz-string

Compress text in JavaScript into strings you can keep in localStorage or put in a URL.

Install
npm install lz-string
Runs in
Browsers and Node.js
License
MIT
Latest release
1.5.0

The problem

localStorage only holds a few megabytes, and URLs have length limits. Text compresses well, but most compression formats produce binary data, which neither of them can store.

What it does

Get started

import LZString from "lz-string";

const packed = LZString.compressToUTF16(text);
const unpacked = LZString.decompressFromUTF16(packed);

Or from the command line, once installed globally:

lz-string input.txt > output.txt

Learn more