GZIP Text Compressor
Paste text, press Compress, and see how much smaller GZIP makes it. Everything runs in your browser with the built-in CompressionStream API, so nothing you type leaves your device.
Your text
Your result
Press Compress to see the result. The sample text is repeated on purpose, so the saving is easy to see.
What Is a GZIP Text Compressor?
A GZIP text compressor takes a piece of text and squeezes it with the GZIP format, the same compression used to shrink web pages before they are sent to your browser. It shows the original size in bytes, the compressed size in bytes, and the percentage saved, plus the compressed data itself as base64 text you can copy. This tool does all of that in your browser with the built-in CompressionStream API. Nothing you type is sent to a server, so it is safe for text you would rather keep private.
How GZIP Compression Works
GZIP works in two steps. First it replaces repeated strings with short references to an earlier copy, so a sentence that appears five times is stored once and pointed at four more times. Then it recodes the result with Huffman coding, giving shorter codes to the characters that appear most often. Text with a lot of repetition, such as logs, JSON, or HTML, can shrink by 70 to 90 percent. Short text or random-looking text compresses poorly, and can even grow, because the GZIP format adds about 18 bytes of header and footer around the compressed data. That is why the result here is always shown honestly, even when the compressed size is larger than the original.
Worked Example
Example, with the sample text loaded in the tool. The sample is three sentences repeated five times, 614 characters in total. Its original size is 614 bytes. GZIP compresses it to about 125 bytes, which is a saving of about 79.6 percent. The saving is so large because the same three sentences repeat five times, so GZIP stores each sentence once and references it again. A short random-looking string behaves very differently: 50 characters of mixed letters and digits compress to about 70 bytes, which is larger than the original, a saving of about minus 40 percent, because there is nothing to repeat and the GZIP header adds its own bytes.
Common Mistakes
Expecting every file to shrink. GZIP only helps when the data has patterns to remove. Text, code, HTML, and JSON compress well. Random data, encrypted data, and files that are already compressed, such as JPEG images and ZIP archives, do not shrink and can grow slightly.
Measuring size in characters instead of bytes. A character is not always one byte. Accented letters and emoji take two to four bytes each in UTF-8, so the byte count is the honest measure of size. This tool counts bytes with TextEncoder, not characters.
Forgetting the GZIP header. Every GZIP stream carries a header and footer of about 18 bytes. On a very short input that overhead alone can make the output larger than the input, which is normal and not a fault in the tool.
Pasting secrets into an online compressor. Many online compressors send your text to a server. This one does not, but as a habit, never paste passwords, keys, or private data into a web tool unless you know it runs entirely in your browser.
Related Tools
Encrypt text in your browser with the AES Encrypt and Decrypt Tool, build a redirect file with the .htaccess Redirect Generator, work out how long a file takes to move with the Download Time Calculator, and convert between units with the Unit Converter.
Frequently Asked Questions
Does my text leave my device?
No. This tool uses the CompressionStream API built into your browser. The text is compressed locally, and nothing is uploaded or stored anywhere.
Why did my compressed text come out larger?
Short or random-looking text has few repeated patterns for GZIP to remove, and the GZIP format adds about 18 bytes of header and footer. When the input is smaller than that overhead, the output is larger than the input. That is normal, and the tool shows the negative saving honestly.
What is the base64 output for?
Compressed GZIP data is binary, so it cannot be pasted into a text field or an email as it is. Base64 turns it into plain text characters, which is the standard way to carry binary data as text. You can decode it back to GZIP bytes and decompress it with any standard GZIP tool.
How do I decompress the output?
Decode the base64 text back to bytes, save it as a .gz file, and open it with any GZIP tool, or decompress it in the browser with DecompressionStream using the gzip format. The original text comes back exactly.
Which browsers support this tool?
CompressionStream is built into recent versions of Chrome, Edge, Firefox, and Safari. If your browser is older and does not support it, the tool says so plainly instead of failing silently.