LZ-String Compress — Compress Text for URLs Online
LZ-String Compress shrinks text using the popular lz-string algorithm and outputs a URL-safe string (the EncodedURIComponent variant), so the result can be dropped straight into a query string or hash fragment. It is ideal for packing application state, JSON payloads, or long text into short, shareable links. Everything runs locally in your browser — no data is sent to a server.
What LZ-String compression is good for
LZ-String is a dependency-free JavaScript library that compresses a string into a much shorter, text-safe form. It shines when you need to move a chunk of data through a channel that is not built for bulk payloads — a URL query string, a hash fragment, an HTTP header, or the browser's localStorage quota.
The classic use case is a "share this" link: a playground or editor serialises its entire state to JSON, compresses it with LZ-String, and appends the result to the URL so a single link fully restores the view — with no backend and no database. This tool emits the URL-safe (EncodedURIComponent) variant, so the output can be pasted straight into a link without any further percent-encoding.
Why the output is URL-safe
LZ-String can output several alphabets. This tool uses compressToEncodedURIComponent, whose alphabet is A–Z, a–z, 0–9, plus the URL-friendly symbols + - and $. Because none of those characters need escaping inside a query string or fragment, you avoid the double-encoding headaches that come from wrapping standard Base64 (which uses / and =) in a URL.
To reverse it, use the LZ-String Decompress tool — it automatically recognises this and every other LZ-String variant. Note that LZ-String output is not compatible with gzip or zlib: only LZ-String can decompress it.
Common Use Cases
- Packing app or editor state into a shareable URL
- Storing large values in localStorage more compactly
- Shrinking JSON payloads before putting them in a query string
Frequently Asked Questions
What LZ-String variant does this use?
It uses compressToEncodedURIComponent, which produces a string containing only URL-safe characters (A–Z, a–z, 0–9, +, -, and $). Decompress it with the LZ-String Decompress tool.
Is LZ-String compressed output the same as gzip?
No. LZ-String is a JavaScript-native LZ-based compressor optimized for short strings and browser use; it is not compatible with gzip or zlib.
Privacy & Security
This tool runs entirely in your browser using client-side JavaScript. No data is sent to a server — your input never leaves your machine. SmartDevBox has no account system, no usage tracking, and no paid tier. See the Privacy & Security page for full details.
Related Tools
- LZ-String DecompressDecompress a URL-safe LZ-String value back to plain text instantly. Free, no sign-up, 100% client-side.
- Base64 EncoderEncode any text or string to Base64 instantly in your browser. Free, no sign-up, 100% client-side. Results copy with one click.
- URL EncoderPercent-encode any string for safe use in URLs instantly in your browser. Free, no sign-up, 100% client-side.