← Back to Tools

Text Compressor

Compress text to a compact string for sharing or storage, then decompress it back again.

Compression ratio: —

How to use the Text Compressor

This tool compresses text using an LZ-based algorithm and outputs a compact Base64 string you can share, store, or embed. Use Decompress to restore the original text from a compressed string.

  1. 1

    Paste your text and click Compress

    Enter any text in the input field and click "Compress." The compressed output appears in the output area along with the compression ratio as a percentage of the original size.

  2. 2

    Share or store the compressed output

    Copy the compressed string and share it via URL query parameters, email, QR code, or paste it into a database field where space is limited.

  3. 3

    Decompress to restore

    Paste a previously compressed string into the input field and click "Decompress" to recover the original text. The tool handles the full round-trip automatically.

  4. 4

    Check the compression ratio

    The stat line shows the compressed size as a percentage of the original. Repetitive text compresses best; short or random text may actually grow slightly.

Frequently asked questions

How does the compression algorithm work?

This tool uses an LZ-based (Lempel-Ziv) compression algorithm. It builds a dictionary of repeated substrings encountered in the input and replaces them with shorter codes. The result is Base64-encoded for safe transmission as plain text in URLs and APIs.

What kinds of text compress well?

Repetitive text compresses best — log files, CSS, JSON with repeated keys, XML, or any content with many recurring patterns. A 10 KB JSON file might compress to 2–3 KB. Short or highly random text often does not compress significantly.

Why does short text sometimes get bigger after compression?

Compression algorithms have overhead for building and encoding their dictionary. For very short inputs, this overhead exceeds any savings — so a 10-character string may produce a 20-character compressed output. Compression benefits kick in once patterns start repeating.

Is compression the same as encryption?

No. Compression reduces size; encryption adds confidentiality. Compressed text is not secret — anyone with the same algorithm can decompress it. For sensitive data, always encrypt after compressing.

What are practical uses for text compression?

Fitting long data into URL query strings, reducing localStorage usage in browser apps, shrinking QR code payloads, compressing repeated config data before database storage, and transferring large text over limited-bandwidth channels.