How Many Colors Can a GIF Have?
Up to 256 per palette. Every pixel stores an 8-bit index (0–255) into a color table, and each table entry is a 24-bit RGB color. So the 256 colors can be any 256 of the 16.7 million RGB colors.
Palette sizes are powers of two: 2, 4, 8, 16, 32, 64, 128 or 256 entries. A GIF can have one global palette for the whole file and a local palette for any frame. With local palettes, an animation can use different colors in different frames, but a normal frame still shows at most 256. (A rare trick stacks several sub-images per frame to show more, but files get huge and some apps display it wrongly.)
Why GIFs Only Support 256 Colors
The GIF format was designed in 1987 when 256 colors was considered generous for computer displays. It uses 8-bit indexed color: each pixel stores an index (0–255) that references a color in a lookup table (the palette). The palette holds up to 256 colors, each defined as an RGB triplet.
The key insight: those 256 colors can be any 256 colors from the full 16.7 million RGB color space. A GIF of a sunset can use 256 shades of orange, red, and purple. A GIF of a forest can use 256 shades of green. The challenge is choosing the right 256 colors for your specific content.
Why Palette Selection Matters
A generic "web-safe" palette uses a fixed set of 216 colors spread across the spectrum. For video content, this produces terrible results because the colors may not match your video at all.
A custom palette analyzes the actual pixels in your video and selects the 256 colors that best represent the content. The improvement is dramatic — colors look natural, gradients are smoother, and details are preserved.
Our converter uses FFmpeg's two-pass approach: first analyze the video to generate an optimal palette (palettegen), then apply that palette to create the GIF (paletteuse). This produces significantly better results than single-pass tools.
Palette Generation Methods
Full Mode (stats_mode=full)
Analyzes all pixels in all frames to build one global palette. Best for videos with diverse, changing content like film clips, action sequences, and music videos where colors vary across frames.
Diff Mode (stats_mode=diff)
Only counts pixels that change between frames. Better for videos with static backgrounds like screen recordings, presentations, and talking-head videos. Produces smaller files because it allocates more palette entries to the changing content and fewer to the unchanging background.
Single Mode (stats_mode=single)
Creates a new palette for every frame. Provides the highest possible quality since each frame gets an optimized palette, but produces larger files. Best for photographic content where color accuracy is critical.
Color Count Tradeoffs
| Colors | Quality | Size Savings | Best For |
|---|---|---|---|
| 256 | Best possible | Baseline | Photographic content |
| 128 | Barely different | 15–25% | Sweet spot for most content |
| 64 | Slight banding | 30–45% | Screen recordings |
| 32 | Noticeable posterization | 45–60% | Simple graphics only |
| 16 | Significant degradation | 60–75% | Logos, pixel art |
Dithering: Simulating Missing Colors
Dithering uses patterns of available colors to simulate colors not in the palette. It is the difference between harsh color banding and smooth-looking gradients.
- No dithering: maps each pixel to the nearest palette color. Fastest, smallest files, but shows visible banding on gradients. Best for flat-color content like logos and pixel art.
- Bayer (ordered): uses a deterministic crosshatch pattern. The regular pattern compresses well, making it the best choice when file size is critical. Slight visible pattern at close inspection. Fewer colors and lighter dithering are two of the methods in how to reduce GIF file size.
- Floyd-Steinberg (error diffusion): distributes quantization error to neighboring pixels. Produces the most natural-looking results for photographic content. Larger files due to random-looking pixel patterns.
- Sierra2: enhanced error diffusion with a wider distribution kernel. Produces results between Floyd-Steinberg and Bayer in both quality and file size. Our recommended default.
Recommendations by Content Type
| Content | Palette Mode | Colors | Dithering |
|---|---|---|---|
| Screencast | diff | 128 | Bayer |
| Film clip | full | 256 | Sierra2 |
| Logo animation | full | 64 | None |
| Photography | single | 256 | Floyd-Steinberg |
Modern Alternatives with Better Color Support
If GIF's 256-color limitation is unacceptable for your content, consider these alternatives:
- WebP animation: 24-bit color (16.7M colors), full alpha transparency, about 64% smaller than GIF in lossy mode (Google’s figures). Supported by 97%+ of browsers.
- APNG: full PNG quality with 24-bit color and 8-bit alpha. Same browser support as WebP. Best when you need transparency with full color.
- MP4/WebM: millions of colors, vastly smaller files. Use
<video autoplay loop muted playsinline>on websites.
Compare all options in our animated formats comparison.
Why Is My GIF Changing Colors?
- One palette for the whole clip. If a clip moves from a blue sky to a red room, a single palette has to cover both, so each scene gets fewer exact colors.
- The palette changes between frames. With per-frame palettes, the same object can be mapped to slightly different colors in each frame, which looks like flicker.
- Dither noise moves. Error-diffusion patterns change from frame to frame and shimmer on flat areas.
- Re-saving an existing GIF picks a new palette from already-reduced colors, so each save drifts further.
The converter on this page builds one palette for the clip with FFmpeg palettegen=max_colors=256:stats_mode=diff, so colors stay consistent between frames and favor the parts that move. It dithers with Sierra-2 and updates only changed rectangles (diff_mode=rectangle).