GIF vs MP4 vs WebP: Best Format for Animations (Size, Quality, Speed)
Oct 29, 2026 · Idea2Grow · 5 min read
Short answer: for websites, use MP4 (or WebM) video set to autoplay, loop, and mute — it's usually 5–10× smaller than a GIF with better quality. Animated WebP is a good middle ground when you need an image file instead of a video. Keep GIF only where video and WebP aren't supported, such as most email newsletters and some chat or documentation tools.
GIF vs MP4 vs WebP at a glance
| Feature | GIF | MP4 (H.264) | Animated WebP |
|---|---|---|---|
| Type | Image (animated) | Video | Image (animated) |
| Introduced | 1987 (animation added 1989) | 2001 | 2010 (animation ~2013) |
| Colors | 256 per frame | Millions | Millions |
| Typical file size | Largest | Smallest (often 80–90% smaller than GIF) | Much smaller than GIF |
| Transparency | Yes (on/off only, jagged edges) | No | Yes (smooth alpha) |
| Sound | No | Yes (can be muted) | No |
| Playback controls | No | Yes (optional) | No |
| Web browsers | ✅ Universal | ✅ Universal via <video> | ✅ All modern browsers (~97%) |
| Email clients | ✅ Most show it (Outlook desktop may show first frame only) | ❌ Rarely plays | ❌ Poor support |
| Messaging/social apps | ✅ Widely supported | ✅ Supported (often converted) | ⚠️ Varies |
| Page speed impact | ❌ Often flagged by Lighthouse | ✅ Recommended replacement | ✅ Good |
| Best for | Email, memes, quick reactions | Website animations, demos, product clips | Animated images that need transparency |
Why GIFs are so big
GIF was designed in the 1980s for simple graphics. Its compression (LZW) works well on flat colors but poorly on video footage, and it stores each frame mostly as a full image. It's also limited to 256 colors per frame, so realistic clips show dithering (speckled noise) and banding. Video codecs like H.264 are far smarter: they store only what changes between frames and use modern compression.
Google's web.dev team showed a typical example: a 3.7 MB GIF became a 551 KB MP4 and a 341 KB WebM — up to about 90% smaller. That's why Lighthouse and PageSpeed Insights include an audit called "Use video formats for animated content," and tools like GTmetrix flag GIFs over 100 KB.
What is each format?
GIF
GIF (Graphics Interchange Format) is an image format from 1987 that supports simple animation. It plays everywhere with no controls, loops automatically, and has no sound — which made it the internet's favorite format for reactions and memes, despite being inefficient.
MP4
MP4 is the standard video container, usually with the H.264 codec. It supports millions of colors, sound, and efficient compression, and it plays in every browser. For more on video containers, see MP4 vs MOV.
Animated WebP
WebP is Google's modern image format, and it supports animation with full color and smooth transparency. Google reports that GIFs converted to animated WebP are substantially smaller — around 64% for lossy WebP and 19% for lossless WebP. Learn more in WebP vs AVIF.
Also worth knowing: WebM and animated AVIF
WebM (VP9 or AV1 video) is often even smaller than MP4 and is supported in modern browsers. Animated AVIF compresses extremely well, but tooling and support are less mature than WebP.
How to replace a GIF with video on a website
A video can behave exactly like a GIF — playing automatically, looping, silent, and inline — with these attributes:
<video autoplay loop muted playsinline width="600" height="338">
<source src="animation.webm" type="video/webm">
<source src="animation.mp4" type="video/mp4">
</video>
- autoplay + muted: browsers only allow autoplay for muted videos.
- loop: repeats like a GIF.
- playsinline: stops iPhones from opening the video fullscreen.
- width and height: prevent layout shift (good for Core Web Vitals).
To convert a GIF to MP4, you can use a video converter or the free command-line tool FFmpeg:
ffmpeg -i animation.gif -movflags faststart -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" animation.mp4
The scale part makes the width and height even numbers, which H.264 requires. To shrink the result further, see how to compress a video without losing quality or use the Video Compressor.
A note on Largest Contentful Paint (LCP)
Image elements (including GIFs) can be the page's LCP element, and huge GIFs make LCP slow. A <video> without a poster image isn't counted as an LCP candidate, so replacing a big hero GIF with a video often improves LCP too. Add a lightweight poster image only if you need something to show before playback.
When a GIF is still the right choice
| Where | Best format | Why |
|---|---|---|
| Email newsletters | GIF (small!) | Most email clients don't play video or WebP |
| Website animations, hero loops, product demos | MP4/WebM video | Far smaller, better quality |
| Animated sticker or icon with transparency (web) | Animated WebP (or Lottie/SVG for vector animation) | Smooth transparent edges, small size |
| Slack, Teams, Discord, messaging | GIF or MP4 | Both are widely supported |
| GitHub README or documentation | GIF (or MP4 where supported) | GIF renders reliably in markdown |
| Social media posts | MP4 | Platforms convert GIFs to video anyway |
| Tutorial screen recordings longer than a few seconds | MP4 with controls | Viewers can pause and seek |
| Simple vector animations (spinners, icons) | CSS/SVG or Lottie | Tiny and sharp — see SVG vs PNG |
How to make GIFs smaller (when you must use one)
- Shorten it. Every second adds frames. Aim for 2–5 seconds.
- Reduce dimensions. A 480-pixel-wide GIF is a fraction of a 1080-pixel one.
- Lower the frame rate to 10–15 fps — smooth enough for most loops.
- Use fewer colors (64–128 instead of 256) for flat graphics.
- Crop to the action and remove static backgrounds.
- Optimize frames with a GIF optimizer that stores only changed pixels.
For email, try to keep GIFs under about 1 MB so they load quickly on phones.
Quality comparison
For real-world footage (people, nature, product videos), MP4 and WebP look dramatically better than GIF because they aren't limited to 256 colors. For flat cartoons and simple UI animations, GIF can look acceptable, but video and WebP will still be smaller. For screen recordings with text, MP4 keeps text sharper at a fraction of the GIF's size.
Accessibility tips
- Avoid flashing content (more than three flashes per second can trigger seizures).
- Give users a way to pause long or distracting animations.
- Add alt text to GIF and WebP images, and a text description or caption for videos that carry information.
- Respect the "reduce motion" setting with the
prefers-reduced-motionCSS media query.
The verdict
MP4 (and WebM) video is the best format for animations on websites, animated WebP is the best image-based alternative, and GIF is best kept for email and places nothing else works. Replacing large GIFs is one of the easiest page-speed wins you can make.
Related format comparisons
Frequently asked questions
Is MP4 better than GIF?
For websites, yes. MP4 files are often 80–90% smaller than the same animation as a GIF, with millions of colors instead of 256. GIF is still better for email, where video rarely plays.
Is animated WebP better than GIF?
Usually. Animated WebP supports full color and smooth transparency and is much smaller than GIF. It works in all modern browsers but not in most email clients.
Why are GIFs so large?
GIF uses 1980s compression designed for simple graphics. It handles video footage poorly and is limited to 256 colors per frame, so animations become large and grainy.
How do I make a video play like a GIF?
Use the HTML video tag with the autoplay, loop, muted, and playsinline attributes. The video then starts automatically, repeats, stays silent, and plays inline like a GIF.
Do animated GIFs hurt SEO?
Large GIFs slow pages down, which can hurt Core Web Vitals such as Largest Contentful Paint. Lighthouse flags them with the audit "Use video formats for animated content."
Can I use MP4 instead of GIF in emails?
Generally no. Most email clients don't play video. Use a small, optimized GIF, or a static image linking to the video.
How do I convert a GIF to MP4?
Use a video converter or FFmpeg. Make sure the width and height are even numbers, use the yuv420p pixel format for compatibility, and compress if needed.
Does Outlook support animated GIFs?
Many modern versions do, but some Outlook desktop versions only show the first frame. Put the key message in the first frame.
Do GIFs support transparency?
Yes, but only fully transparent or fully opaque pixels, which can leave jagged edges. Animated WebP supports smooth partial transparency.
What frame rate should a GIF use?
10–15 frames per second is usually smooth enough for loops and keeps file size down. Higher frame rates add size quickly.
Is WebM better than MP4 for web animations?
WebM is often smaller, but MP4 (H.264) has the broadest support. The best practice is to provide WebM first and MP4 as a fallback.
Do social media platforms keep GIFs as GIFs?
Many platforms convert uploaded GIFs to video behind the scenes to save bandwidth, so uploading MP4 directly often gives better quality.