Skip to content
ToolPlankDEV
Encoders & Decoders
100% In-Browser Execution

Updated:

Gzip Compress Online

Type text or drop a file and get gzip data back as a .gz download, Base64 or hex. This gzip compress online tool offers gzip, zlib and raw deflate with levels 1 to 9, shows how many bytes you save and decompresses the result again to prove it matches. Nothing is uploaded.

Processing in browser...

Loading the tool. It runs entirely in your browser, so your data is never uploaded.

More free tools you may need next.

Quick Guide

How to use Gzip Compress

Simple step-by-step instructions to get the exact output you need.

  1. 01

    Add text or a file

    Type or paste text into the left box, or drop any file on it, or press Upload. Sample loads a short JSON text.

  2. 02

    Choose the format and level

    Pick gzip, zlib or raw deflate, then a level from 1 (fastest) to 9 (smallest). The result updates as you change them.

  3. 03

    Check the size and the round trip

    The strip shows the original and compressed size, the percent saved and a round-trip check. A warning appears when the data did not shrink.

  4. 04

    Copy or download

    Choose Base64, URL-safe Base64 or hex for the text form and press Copy, or press Download to save a real .gz file.

How to gzip text online

To gzip compress online, type or paste text and the compressed data appears at once. The text is turned into UTF-8 bytes, compressed with the deflate method and wrapped in the gzip format. You can copy it as Base64 or hex, or download it as a .gz file that any gzip program opens.

How much it shrinks depends on the data. Take a JSON array of 200 small objects shaped like {"id":0,"name":"item 0","active":true}, 8,481 bytes long in all. At level 6 it compressed like this:

  • gzip: 1,007 bytes, 88.1% saved
  • zlib: 995 bytes, 88.3% saved
  • raw deflate: 989 bytes, 88.3% saved

The three formats hold the same compressed data. The small differences are the size of the header and the checksum around it.

Gzip, zlib or raw deflate

Pick the format the other side expects. If you are not sure, gzip is the safest choice.

  • gzip is the .gz format. HTTP uses it for Content-Encoding: gzip, and the gzip command and most languages read it.
  • zlib has a two-byte header and an Adler-32 checksum. It is used by PNG, Git objects and many libraries, where the code calls it deflate.
  • Raw deflate has no header and no checksum. Use it for ZIP internals and for protocols that ask for it by name.

Mixing them up is a common cause of errors such as incorrect header check. The Gzip Decompress tool detects all three from the first bytes.

Compression levels

Level 1 is the fastest and level 9 searches hardest for savings. The default, 6, is a balance. On large text the gap between levels is often small, and on small input it can be nothing, so try two levels and read the Saved line before choosing.

The level changes only the size and the time, never the content. Any level decompresses with any gzip program.

Gzip to Base64 and hex output

Compressed data is binary, so putting it in JSON, an environment variable, a config map or a URL needs a text form. Base64 is the usual one, and gzip Base64 strings start with H4sI. Base64 URL-safe swaps the two symbols that break URLs and drops the padding. Hex doubles the size but is easy to read byte by byte.

Base64 makes the data about a third larger, so compressing text and then Base64-encoding it can be bigger than the original for short input. Use Download when you can keep the file as binary.

Python
import base64, gzip
text = base64.b64encode(gzip.compress(data.encode("utf-8"))).decode("ascii")

Store the file name and time, or keep output repeatable

A gzip header can hold the file name and the modified time. By default this tool leaves both empty and writes a zero time, so the same input always gives the same bytes, which is handy for tests and for comparing outputs.

Switch on Store name and time to write them. For an uploaded file the name and the file's modified time are used. For typed text the name is data.txt and the time is now. The option applies to gzip only, because zlib and raw deflate have no place for them.

Why a file can get bigger

Compression finds repeated patterns. Data that is already compressed, such as PNG and JPEG images, ZIP archives and MP4 video, has few patterns left, and random data has none. A gzip file also adds about 18 bytes of header and trailer, so a very small input can grow.

The built-in sample is a good example. The 169-byte JSON compresses to 152 bytes, only 10.1% saved. When the result is not smaller, the strip says so in red and you can skip compressing that data.

What the round-trip check proves

After compressing, the page decompresses its own result and compares it with your input, byte for byte. A pass means the compressed data can be read back to exactly what you gave it. The same library does both steps, so it catches mistakes in the output but does not replace a test in your own program. The format is the standard one, and the compressed bytes are also read by other gzip programs.

Limits: input up to 50 MB, or 20 million characters of typed text. Brotli, ZIP archives with several files and tar are not covered.

Privacy

Files you compress can be private. Everything runs in your browser and nothing is uploaded. The Privacy Policy explains what the site stores.

Related tools: Gzip Decompress, File to Base64, Base64 Encode and Text to Hex.

Frequently Asked Questions

Technical Q&A for Gzip Compress

Common questions about edge cases, character encoding, and privacy guarantees.

Paste the string into the left box and choose Base64 or hex for the text form. The compressed data appears on the right, and Copy puts it on the clipboard.

It depends on how repetitive the text is. Repetitive text such as JSON, logs and HTML often loses more than half its size, while short or random text shrinks little. The Saved line shows the exact figure.

The data had few patterns to remove, which is typical for images, archives and video, or it was very small, so the header and trailer outweighed the savings.

They share the same compression with different wrappers. Gzip has a header and a CRC-32, zlib a short header and an Adler-32, and raw deflate has neither.

Level 6 is a good default. Use 9 when size matters more than time, and 1 when speed matters. Compare the Saved line, because the gap can be small.

Leave the output set to Base64 and press Copy. Choose Base64 URL-safe if the text goes into a URL or a filename.

Yes. Drop any file on the left box or press Upload, up to 50 MB, and download the .gz file. The original name is kept in the file name, and optionally in the header.

Yes, as long as Store name and time is off. The header then holds no name and a zero time, so the output is repeatable.

No. It writes gzip, zlib and raw deflate only. ZIP archives of several files and brotli are different formats.

No. The data is compressed in your browser, so it stays on your device.