Compress GIF to Size
Published Updated
Type a size or press 1, 5 or 10 MB and the tool cuts the palette from 256 colors toward 8, then shrinks the picture in 10% steps, keeping every frame. A 2,784,074-byte test GIF fit 1 MB at 16 colors and full size.
What the search tries, in order
A GIF stores each pixel as an index into a Palette. A table of colors that an indexed image points into. In a GIF each pixel is a number from 0 to 255, and the palette says which of up to 256 colors that number stands for. Read the guide, compressed with LZW. Lempel-Ziv-Welch, a lossless method that replaces repeated runs of data with short codes from a table it builds as it goes. GIF uses it on each frame's palette indexes, with codes of up to 12 bits. Read the guide, so there is no quality dial to turn. The tool has two levers instead. For each scale from 100% down to 10% in 10% steps, it tries palettes of 256, 128, 64, 32, 16 and 8 colors, and stops at the first file that fits. That is at most 60 encodes. Palette shrinks are tried at full size before any pixels are removed.
Every frame is kept, with one shared palette across the whole animation. A GIF can hold only palettes of up to 256 entries, per the MDN image format guide, and one transparent index. Transparency here is on or off: pixels under 50% opacity become clear.
Results on a 36-frame test GIF, in four browsers
The test GIF is a generated, photo-like grainy picture panning across 36 frames of 480 x 270 pixels, 2,784,074 bytes, made with the Pillow library. We ran this page's own tool on it in Google Chrome 156, Chromium 153 (Playwright build, not Google Chrome), Firefox 155 and Playwright's WebKit build (not the Safari app), with its own target buttons and box, one run per cell. Each cell gives the file the tool offered, its colours and scale, and the time from the click to the download link.
| Target | Chrome 156 | Chromium 153 | Firefox 155 | WebKit build | Encodes |
|---|---|---|---|---|---|
| 1 MB (preset) | 874,863 B, 16 colours, full size, 1.3 s | 874,863 B, same, 1.2 s | 874,863 B, same, 3.0 s | 874,863 B, same, 1.1 s | 5 |
| 512 KB | 501,162 B, 8 colours, 90%, 2.6 s | 503,037 B, same, 2.4 s | 503,037 B, same, 5.8 s | 500,974 B, same, 2.6 s | 12 |
| 200 KB | 160,944 B, 8 colours, 40%, 6.2 s | 160,944 B, same, 5.9 s | 160,944 B, same, 13.6 s | 160,857 B, same, 5.5 s | 42 |
| 100 KB | 82,369 B, 16 colours, 20%, 6.9 s | 82,369 B, same, 6.7 s | 82,369 B, same, 12.6 s | 82,369 B, same, 6.3 s | 53 |
| 10 KB (missed) | 20,920 B, 8 colours, 10%, 7.2 s | 20,920 B, same, 6.7 s | 20,920 B, same, 11.0 s | 20,906 B, same, 7.6 s | 60 |
| 2.5 MB | 2,363,348 B, 256 colours, full size, 0.3 s | same, 0.3 s | same, 0.6 s | same, 0.3 s | 1 |
Every row kept all 36 frames and their 80 ms delay. Only the scaled rows differ between browsers, by up to 2,063 bytes, because each browser shrinks the frames with its own canvas smoothing before the palette is built. Firefox 155 took 1.4 to 2.7 times as long as the others. The page can freeze for several seconds while the search runs, because it is one blocking pass.
A flat 30-frame cartoon of 41,022 bytes under a 50 KB goal came back untouched in all four engines, with the card saying it was already under the target and no encode made. Under 30 KB it became 29,307 bytes (8 colours, 90%) in Chrome 156, Chromium 153 and Firefox 155 and 29,460 bytes in the WebKit build.
Compressing a GIF
Step 1
Drop the GIF
The file is decoded frame by frame first. Its original size is shown beside the preview.
Step 2
Set a target
Press 1 MB, 5 MB or 10 MB, or type a number and pick KB or MB. A typed value overrides the buttons.
Step 3
Compress and download
The search runs once, then a card gives the new size, the colors, the scale and a before and after animation.
Things to know first
- Delays are read from the file, and the GIF format counts them in hundredths of a second (W3C GIF89a specification).
- Photographic GIFs shrink the most; flat graphics with few colors barely respond to a smaller palette, so the tool falls through to lowering the scale.
- Results are named with
-compressed.gif, and a file already at or under the target is handed back as it was. - For a much smaller animation at the same size, try GIF to WebP or GIF to MP4. For a one-step trim without a target, use GIF Compressor.
GIF size questions
Why does the result look grainy or banded?
Fewer colors means fewer shades. The encoder maps each pixel to the nearest palette color and applies no dithering, so smooth gradients break into bands first at 32, 16 and 8 colors. If that is too ugly, aim for a larger target.
Does the animation keep its speed?
Yes, to the nearest hundredth of a second, the unit the GIF format counts delays in. A frame with a delay of 0 is given 100 ms. The output always loops forever, even if the original played once.
Is 5 MB here the same as 5 MB on another site?
Not always. The tool counts 1 MB as 1,048,576 bytes, so 5 MB is 5,242,880 bytes. A site that counts decimal megabytes could refuse a result near the top. Type 4.7 MB to leave a margin.
What if my GIF cannot reach the target?
After all 60 tries it offers the smallest file it made and says it is compressed as small as possible. For the 36-frame test GIF that was the last try, 8 colours at 10% scale: a 10 KB goal ended at 20,920 bytes (48 x 27 pixels) in Chrome 156, Chromium 153 and Firefox 155, and 20,906 bytes in the WebKit build. A very small GIF can be the exception. For a 2 x 2-pixel, six-frame black-and-white test GIF under 0.1 KB, the 10% try (1 x 1 pixel) blended the frames into greys and came to 195 bytes, so all four engines offered the 185-byte full-size file instead.
How large a GIF can it open?
Up to 1,000 frames, 10,000 pixels on a side, and 500 MB once decoded to raw pixels. Beyond those limits it shows a message instead of starting.
Is the GIF uploaded anywhere?
Not by this page. Decoding, scaling and re-encoding are done by code in the page, and no request carries the file to our servers.
Why did a smaller target give a file with more colours?
Because the search lowers colours before scale at each size and stops at the first file that fits. The flat 30-frame test cartoon fitted 30 KB at 8 colours and 90% scale, but for 10 KB nothing fitted until 30% scale, where 64 colours already did: 9,915 bytes at 120 x 90 pixels in Chrome 156, Chromium 153 and Firefox 155, 9,977 bytes in the WebKit build.
Is a transparent background kept, and do short delays survive?
In our test, yes. A 6-frame GIF with a transparent background stayed transparent at its corner after compressing to 3,035 bytes in all four browsers. A GIF with delays of 0, 10, 20, 70 and 1,000 ms came out with 100, 10, 20, 70 and 1,000 ms: the 0 became 100 ms, as the tool's decoder reads it. A GIF that played once came out set to loop forever.
Why does the same target give slightly different files in different browsers?
Only when the frames are scaled. At full size every browser in our test wrote the same 874,863 bytes for the 1 MB goal. At 90% and below each browser smooths the shrunken frames in its own way, so the 512 KB goal gave 500,974 to 503,037 bytes, all at 8 colours and 90% scale.
Related guide
Making a GIF from a video: size, frame rate and quality. The guide explains the order of the size search, palette first and then scale, and when a target cannot be reached.