File Formats
What Is GIF? 256 Colors, Animation and LZW Compression
GIF has been around since 1987: limited to 256 colors, but still alive thanks to animation. Here is how it works, why it produces large files and when to choose another format.
Author: Hemen Dönüştür Editör EkibiPublished: 7 min read

GIF (Graphics Interchange Format) is one of the oldest image formats on the web. It long ago lost photographs to JPG and graphics to PNG, but it is still the first thing that comes to mind for short, looping animations. This article explains how GIF began, how its compression and animation work, what the 256-color limit really means and which formats you can consider instead.
A short history
GIF was developed by CompuServe, one of the large online services of the time. According to the UK National Archives' PRONOM registry, the first version, GIF87a, was released on 15 June 1987. The next version, GIF89a, takes its name from 1989; the specification text, listed by PRONOM and hosted by the W3C, is dated 31 July 1990. 89a added the Graphic Control Extension, which defines frame delay, transparency and the disposal method, along with comment, plain text and application extensions. Today's animated GIFs are built on these extensions.
The best-known chapter of GIF's story is the patent dispute. GIF is compressed with LZW, an algorithm patented by Unisys. According to the Library of Congress format description, GIF became notorious in 1994 when Unisys began charging fees to license LZW. That led to the development of PNG as a patent-free alternative. According to the same source, the Unisys US patent expired in June 2003 and the European and Japanese patents in June 2004, so no license is needed to use GIF today.
How GIF works
The palette and the 256-color limit
GIF does not store each pixel's color directly; it stores an index into a color table (palette). According to the specification, a color table can hold at most 256 entries, each a 24-bit RGB color. A global table can apply to the whole file, and each frame can also have its own local table. Logos and illustrations with few colors fit within this limit easily, while photos with thousands of tones show banding or dithering patterns when reduced to 256 colors.
LZW compression
The pixel indexes are compressed losslessly with LZW, which uses variable-length codes; the specification allows codes to grow up to 12 bits. LZW works by adding repeating pixel sequences to a dictionary, so it does well on large flat areas of color and poorly on noisy photographs.
Transparency
In GIF89a, the Graphic Control Extension can mark one palette color as "transparent". This is on/off (binary) transparency: a pixel is either fully visible or fully transparent. That is why semi-transparent shadows and soft edges look jagged in GIF, and why a light "halo" around the edges on a colored background is such a common problem.
Animation
An animated GIF is a sequence of frames in a single file. Each frame's Graphic Control Extension sets how long it stays on screen, in hundredths of a second, and how its area is cleared before the next frame. Looping information is kept in an application extension. Optional interlacing lets the image appear gradually while it loads.
Frame disposal methods
The specification defines four values for how a frame's area is treated after it has been shown: no disposal specified, leave the frame in place, restore the area to the background color, and restore the area to what was there before. In well-made animations only the region that changes is written as a new frame and the rest is carried over from the previous one, which is what keeps the file small. That is why tools that edit a GIF have to work on full images composed with these rules, not on the raw frames one by one.
How widely is GIF used?
W3Techs data from October 2026 shows GIF on 13.2% of the websites it monitors. According to the HTTP Archive Web Almanac 2024, 16.8% of images on mobile pages are GIFs; the report says 32% of those GIFs are animated. It also notes that about 6% of all image requests are 1x1 pixel images, most likely tracking beacons and spacer GIFs, so GIF's high share does not come from animations alone.
On efficiency, GIF lags far behind. The same report puts the median GIF at 6.7 bits per pixel, against 3.8 for PNG, 2.0 for JPEG and 1.3 for WebP. For animated GIFs the median rises to 32.6 bits, while non-animated GIFs stay at 3.5 bits.
What can replace GIF?
MDN's image format guide sees GIF as a good choice for basic images and animations, but suggests PNG for lossless and indexed still images and WebP, AVIF or APNG for animation sequences. For long animations or ones made from real footage, video is far more efficient: in the example on web.dev, a 3.7 MB GIF shrinks to 551 KB as MP4 and 341 KB as WebM.
| Need | Recommendation |
|---|---|
| Still logo, icon, flat-color graphic | PNG or SVG |
| Short animation with few colors (such as a loading spinner) | GIF, APNG or animated WebP |
| Animation made from video footage or a screen recording | A muted, looping MP4 or WebM video |
| Animation that must play everywhere (email, messaging) | GIF; still the format with the widest compatibility |
Email clients and some messaging apps do not play video or show animated WebP. That universal compatibility is the real reason GIF has survived for more than three decades.
Common problems
The GIF is too large
The number of frames, the pixel dimensions and the amount of motion all increase file size directly. Making it smaller in dimensions, cropping the frames or cutting out a short section are the most effective fixes; for long clips, switching to video is the better choice.
Colors look banded or dotted
This is the natural result of the 256-color limit. Smooth gradients such as skies or skin tones are affected the most. For photo-like content, use JPG, WebP or video instead of GIF.
There is a white halo around the edges
Because transparent GIFs cannot be semi-transparent, an image prepared on a light background shows its in-between edge tones when placed on a dark one. For transparent images with soft edges, use PNG or WebP.
The animation stopped after conversion
PNG and JPG do not carry animation, so an animated GIF converted to either format keeps only one frame.
Tips for working with GIF
- To grab a still image, convert GIF to PNG. The first frame of the GIF is saved as a lossless PNG with its transparency.
- To make an animated GIF smaller in dimensions, use the image resizer. Animated GIFs keep every frame and its display time when resized (up to 600 frames).
- To crop an animation, the image cropper applies the same crop to every frame and keeps the frame timings.
- To reduce file size, the image compressor keeps animated GIFs as GIFs with all their frames, while still GIFs are converted to WebP by default to make them smaller.
- To turn another image into a GIF, choose GIF as the target in the image converter. The output is a single frame with up to 256 colors, and semi-transparent areas are reduced to on/off transparency.
- All of this runs in your browser, so your files never leave your device.
Frequently Asked Questions
Is GIF lossy?
LZW compression is lossless. But converting a full-color image to GIF requires reducing it to 256 colors, and that color reduction step is where the loss happens.
Is there a difference between a GIF and an animated GIF?
The format is the same. A GIF with one frame is still, and a GIF with several frames is animated. Frame delays and looping information are stored in extensions inside the file.
Why is GIF still used?
Because it plays almost everywhere without any setup: in browsers, email clients, chat apps and old software. More efficient alternatives do not yet offer that compatibility in every environment.
Does it make sense to convert GIF to MP4?
If you are showing it on your website, usually yes. In the web.dev example the video versions take roughly a seventh to a tenth of the GIF's size. A video played with the autoplay, loop, muted and playsinline attributes behaves just like a GIF on the page.
How many colors can a GIF have?
Each color table holds at most 256 colors. Technically, because each frame can carry its own local table, a multi-frame GIF can show more colors in total, but within a single frame the limit is 256.
Sources
- CompuServe: Graphics Interchange Format Version 89a (W3C copy)
- The National Archives PRONOM: Graphics Interchange Format 87a
- The National Archives PRONOM: Graphics Interchange Format 89a
- Library of Congress: GIF 89a format description
- MDN: Image file type and format guide
- web.dev: Replace animated GIFs with video for faster page loads
- W3Techs: Usage statistics of image file formats for websites
- HTTP Archive Web Almanac 2024: Media


