Motion

GIF vs MP4 vs WebM: which format for loops

GIF is the format everyone knows and almost nobody should use for the web. It is also the only one that works in an inbox. Here is which to pick, where, and why.

GradientlyVerified Gradiently account··5 min read
Cover: Copper Compass · GR·HVTH·0E

The short version

  • For websites and social media, MP4 and WebM are usually much smaller than GIF for the same loop and show smooth colour.
  • GIF can show at most 256 colours in each frame, which makes gradients band or look speckled.
  • GIF remains the practical choice for animation in email, because most email clients don't play video.
  • WebM is often smaller than MP4, but MP4 plays almost everywhere, so websites commonly offer both.
  • Animated WebP and AVIF are modern image formats that replace GIF on websites, but they are not a safe choice for email.
On this page

GIF vs MP4 is decided by where the loop will play. On websites and social media, MP4 (and its open cousin WebM) is almost always the right choice: files are usually far smaller, colour is smooth and playback is efficient. GIF is still the right choice in one place, email, because most inboxes show animated GIFs and very few play video. Everything else in this guide is detail on that rule.

What each format actually is

GIF is an image format from the late 1980s that can hold several frames. It stores each frame with a palette of at most 256 colours and compresses each frame on its own terms. MP4 and WebM are video formats. They use modern video codecs, such as H.264 in MP4 and VP9 or AV1 in WebM, which store what changes between frames rather than every frame in full. For a loop where most of the picture changes slowly, that difference is enormous.

FeatureGIFMP4WebM
ColoursUp to 256 per frameMillionsMillions
File size for a loopLargestSmallOften smallest
TransparencyOn or off per pixel, no soft edgesNoYes, in some browsers
SoundNoYesYes
WebsitesYes, as an imageYes, as a videoYes, in modern browsers
EmailMost clientsRarelyRarely
Social uploadsVaries by platformEverywhereSome platforms
The broad picture. Support for specific platforms and inboxes changes, so check the place you are publishing.

Why gradients look bad as GIFs

A smooth gradient across a 1080 pixel frame can use thousands of distinct colours. A GIF frame can hold 256 at most. The encoder has two choices: round colours to the nearest one in the palette, which produces visible stripes, or scatter pixels of neighbouring colours to fake the in-betweens, called dithering, which looks speckled and makes files bigger. Neither looks like the gradient you designed.

An exaggerated view of what a limited palette does to a gradient. Real GIFs have more steps, but on dark, subtle gradients the bands still show.

Grain helps a little, because noisy images hide palette limits better than clean ones. But the real fix is not to use GIF where video is possible. Gradient banding explains the same problem in still images.

MP4 or WebM for websites

For a website, replace GIFs with a video element that behaves like one: autoplaying, muted, looping and inline. web.dev's guide to replacing animated GIFs with video explains the approach. Offer WebM first, since it is often smaller, and MP4 as the fallback that plays almost everywhere.

html
<!-- Instead of <img src="loop.gif" alt=""> -->
<video autoplay muted loop playsinline width="600" height="600"
       poster="loop-poster.jpg">
  <source src="loop.webm" type="video/webm">
  <source src="loop.mp4" type="video/mp4">
</video>
A video that behaves like a GIF. Width and height stop the layout jumping as it loads.

Two other formats are worth knowing. Animated WebP and animated AVIF are image formats, used in an ordinary img tag like a GIF, but with full colour and much better compression. Modern browsers support both. They are handy where a CMS or platform only accepts images, but not for email. For full-width backgrounds, read video backgrounds on websites.

Loops for social media

Social platforms are built around video, and MP4 is the format they all accept. Where a platform takes a GIF upload, it often handles it differently from a normal video, so a GIF is rarely an advantage. Export your loop as MP4 at the platform's size, in H.264, and let the platform do the rest. Animated posts vs static covers sizes and settings.

Loops in email: still GIF

Most email clients don't play video, so an animated GIF is the practical way to put motion in an email. Keep it small and treat the first frame as the fallback: some clients, including some versions of classic Outlook for Windows, show only the first frame. Put the message in that frame so nothing is lost. Our guides to email header design and gradients in email cover the rest.

  1. 1

    Keep it short

    Two to six seconds is plenty in an email; every frame adds weight.

  2. 2

    Reduce the size and frame rate

    Export at the width it displays, often 600 pixels, and at a lower frame rate, such as 10 to 15 frames per second, for slow movement.

  3. 3

    Put the message in frame one

    Readers who only see the first frame should still get the point.

  4. 4

    Check the file size

    Large GIFs load slowly on phones. If it is heavy, cut length, size or colours before anything else.

Converting between GIF and MP4

ffmpeg, a free command-line tool, handles both directions. Turning video into a good GIF needs a custom palette built from the video itself; turning a GIF into MP4 is simpler.

bash
# MP4 to GIF: 15 fps, 600 px wide, with a palette made from the clip
ffmpeg -i loop.mp4 -vf "fps=15,scale=600:-1:flags=lanczos,split[a][b];[a]palettegen[p];[b][p]paletteuse" -loop 0 loop.gif

# GIF to MP4: H.264, even dimensions, ready for the web
ffmpeg -i loop.gif -movflags +faststart -pix_fmt yuv420p \
  -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" loop.mp4

# MP4 to WebM (VP9)
ffmpeg -i loop.mp4 -c:v libvpx-vp9 -crf 34 -b:v 0 -an loop.webm
palettegen and paletteuse pick the 256 colours that suit this clip, which is the biggest single improvement to GIF quality.

Which format to use, at a glance

Where it playsUseWhy
Website hero or backgroundWebM with MP4 fallbackSmallest files, smooth colour
Inline animation in an articleMP4 video, or animated WebPMuch lighter than GIF
Instagram, TikTok, LinkedIn, XMP4 (H.264)What platforms expect
EmailGIFThe animation most inboxes show
Chat apps and stickersWhatever the app asks forEach app has its own rules

If you make loops in Gradiently, the Studio exports both: a video (MP4 where your browser can record it, otherwise WebM) up to 1080p, and a GIF with a choice of quality that is kept under 15 MB. Make sure the loop joins cleanly whichever you choose; see seamless loops.

Questions people ask

Is MP4 better than GIF?

For websites and social media, yes: MP4 files are usually far smaller and show smooth colour, while GIF is limited to 256 colours per frame. GIF is still the better choice for email.

Why do my gradient GIFs look striped?

GIF can hold at most 256 colours per frame, so smooth gradients are rounded into bands or dithered into speckles. Use video where you can, or build a custom palette when exporting.

Should I use WebM or MP4?

On websites, offer WebM first because it is often smaller, with MP4 as a fallback because it plays almost everywhere. For social uploads, use MP4.

Can I put a video in an email?

Very few email clients play video. Use an animated GIF, keep it small and make sure the first frame carries the message, since some clients show only that frame.

What is animated WebP?

It is an image format that can hold animation with full colour and better compression than GIF. Modern browsers support it, but email clients generally don't.

Share this guide

Written by GradientlyVerified Gradiently account

The team behind Gradiently, a design tool built around Marks: living gradients that make everything you design look like yours.

See our profile
All Motion guides