Convert GIF to WebM

Converting GIF to WebM produces the smallest file that will replace the animation on a page you control: VP9 video in a container built for the web. In our testing a 448 KB GIF became a 19 KB WebM, playing identically. The conversion runs in your browser.

  • Where it runs In your browser. The file is never uploaded.
  • Lossy Some detail is traded for size. WebM cannot hold everything a GIF can.
  • File size limit Up to 100 MB per file, free, without an account.
  • Worth knowing The result has no sound, because a GIF has none to carry. Each frame keeps its own timing, so an animation with irregular delays plays at the speed it was authored at rather than an averaged one.

Up to 100 files at once. Mixed formats are fine.

WebM is the right answer when you can serve two files

The reason to choose WebM over MP4 is not that it is better in the abstract; it is that a video element can list more than one source and the browser takes the first it understands. Put the WebM first and the MP4 after it, and every visitor gets the smaller file where their browser supports it and a working file where it does not.

That only works if you own the markup. A GIF being sent to a client, posted to a forum or dropped into a slide deck has no fallback mechanism, and there WebM is a worse choice than MP4 for a reason that has nothing to do with the codec. This page assumes you are editing the HTML yourself.

What VP9 does that H.264 does not

Both codecs work the same way in outline: store one complete frame, then store the differences. VP9 arrived roughly a decade later and spends considerably more effort per frame deciding how to partition the picture and where to search for matches, which buys real bytes on material that repeats.

GIF material is unusually good for it. Flat colour, hard edges, large unchanged regions and synthetic motion are all cases where a bigger search finds more, so the gap between VP9 and H.264 on a converted GIF is wider than the gap on camera footage. The cost is encoding time, which you pay once, in this tab, rather than on every page load.

WebM was designed to start playing before it has arrived

The container’s record here lists it as streamable, and that is the second saving on a page. A browser can begin playing a WebM from its first bytes, so the animation starts while the rest is still coming down.

A GIF cannot do that in any useful sense. Browsers will show early frames as they arrive, but the loop does not run properly until the whole file has landed, which on a slow connection means a static first frame sitting there for seconds. Replacing a GIF with a WebM changes the shape of that wait as well as its length.

The alpha channel WebM could carry and this file does not have

WebM is one of the very few video formats capable of storing transparency, and its record in this registry says so. That capability is real, and it is worth knowing about because it makes WebM the format people reach for when they want a video that floats over a page background.

The file this conversion writes does not use it. The video track is opaque, so a GIF whose background was declared transparent loses that on the way through, and there is no background-colour setting on this pair to control what replaces it. If transparency is the point of the animation, animated WebP is the honest recommendation: it keeps the alpha channel and it plays everywhere.

The 256-colour palette is a ceiling VP9 cannot lift

Every frame of a GIF is drawn from a palette of at most 256 colours. Whatever smooth gradient or soft shadow the animation started with was reduced to that when the GIF was written, often with dithering applied to hide the steps.

VP9 stores what it receives and imposes no palette of its own, so the animation does not get worse. It also cannot get better, and dithering is actively expensive: it is noise, and noise is the one thing that defeats a video codec’s search for redundancy. A heavily dithered GIF produces a larger WebM than a flat one of the same size, and raising the quality band spends bytes preserving the dither pattern rather than the picture.

Frame timing comes across as the GIF authored it

GIF delays are per frame and stored in hundredths of a second, so a GIF frequently runs at rates no camera ever produced — 12.5 frames a second, or several different rates inside one file. The conversion carries each frame’s own duration into the video rather than resampling to a constant rate.

A stored delay of zero is common and means "as fast as the display allows"; browsers have long treated it as 100 milliseconds and so does this conversion. The practical result is that an animation timed by eye in a GIF editor plays at the same speed as a WebM, which is not something a fixed frame rate would have preserved.

Even dimensions, and why your WebM may be a pixel wider

Both video codecs used on this site want even pixel dimensions, and a GIF is under no such obligation. Widths and heights are rounded up to the next even number before the first frame is drawn, so a 405-pixel-wide GIF produces a 406-pixel-wide WebM.

Rounding up adds a column rather than removing one, which keeps the edge of the animation. If the video is laid out with a fixed CSS width the extra pixel never surfaces; if you are matching it against a background image pixel for pixel, it is worth knowing the number moved.

What to do with the GIF in the markup afterwards

Replacing an image element with a video element is not a like-for-like swap and it is the step most likely to go wrong. The video needs an explicit width and height or an aspect-ratio rule, or the page reflows when it loads — which converts a bandwidth problem into a layout-shift problem and leaves the performance report no happier.

A poster frame is the other thing worth adding. Without one there is a blank rectangle until the first frames decode, where the GIF at least showed something. Exporting the first frame as a small WebP or PNG covers it.

Nothing about the GIF leaves the browser

The frames are read by the browser’s own image decoder and encoded by its own video encoder, in the tab you are looking at. There is no server in the path, no queue, no account and no daily allowance, and a batch takes 100 files at once.

That decoder is not present everywhere. Where it is missing the page says so and names browsers that have it, rather than quietly sending the file elsewhere to be finished — which is the one thing that would make the claim above untrue.

How to convert a GIF into a WebM

  1. Drop the animated GIF onto this page, or click to choose it.
  2. Each frame is decoded and re-encoded as VP9 video, in your browser.
  3. Download the WebM and list it as the first source, with an MP4 behind it.

GIF against WebM: 1989 storage against a 2013 codec

GIF compared with WebM
GIFWebM
Full nameGraphics Interchange FormatWebM Video
File extension.gif.webm
Media typeimage/gifvideo/webm
CompressionLossless — nothing is discardedLossy — file size is bought with quality
First published19872010
Published byCompuServeGoogle
SpecificationGIF89a
LicensingOpen standardOpen standard
Standing todayLegacy, still read everywhereCurrent
Bit depth8
Colour it can describeindexed palette
Largest image65,535 px per side
Opens in a browserEvery browserEvery browser
Considered insteadWebP, MP4MP4, MKV

What survives

Transparency survives. Both GIF and WebM store an alpha channel, so a cut-out stays cut out and nothing is filled in behind it.

Opening the result

WebM is a container rather than a single format. What actually plays is the codec inside it — usually VP8, VP9 and AV1 — which is why two files with the same extension can behave differently on the same device.

GIF dates from 1987 and is largely superseded. WebM is what current software writes, so the conversion is as much about staying readable as about the file itself.

The usual programs do not overlap: GIF opens in GIMP, Adobe Photoshop and ImageMagick, WebM in VLC and FFmpeg — so whoever receives the result needs something from the second list.

What each format is for

GIF is CompuServe's format, published in 1987. It records 8 bits per channel.

WebM comes from Google and dates from 2010. VLC and FFmpeg all read it.

GIF was published in 1987 and WebM in 2010. The older one is generally the safer file to hand to somebody; the newer one usually does the job in fewer bytes.

GIF to WebM: VP9, fallbacks and transparency

Is WebM smaller than MP4 for the same animation?

Usually, and often by a fifth or more. VP9 is a newer codec than H.264 and spends more effort per frame to find redundancy, which shows up most on flat, synthetic material — exactly what a GIF usually is. In our own testing on a 448 KB GIF the WebM came out at 19 KB against 23 KB for MP4.

Do I still need an MP4 as well?

It is the safe answer. A video element accepts several source elements and the browser takes the first one it can play, so listing the WebM first and an MP4 after it costs one line and removes every doubt about older devices, embedded browsers and in-app webviews. If you serve only one file, MP4 is the one that never surprises you.

Which codec is inside the WebM?

VP9 for the picture, and no audio track, because a GIF has no sound to carry. WebM is defined around VP8, VP9, AV1 and Opus, and VP9 is the pairing chosen here: it is what the container exists for and it is decoded by every browser that opens WebM at all.

Can the WebM keep the GIF’s transparent background?

Not from this conversion. WebM is one of the few video formats that can carry an alpha channel at all, but the video track written here does not have one, so a GIF with a transparent background comes out without that transparency. If a floating logo animation is the goal, animated WebP keeps transparency and plays in every current browser.

Will it play in Safari?

Modern Safari plays VP9 in WebM. Older versions on older hardware do not, and that is the entire reason to keep an MP4 as a second source rather than to avoid WebM. Serving both means the browser picks and you never have to know which one it took.

Does my file get uploaded?

No. The GIF is decoded frame by frame by the browser’s own image decoder and encoded as VP9 in the same tab. Nothing is sent to a server, there is no account and no daily allowance, and a batch runs to 100 files at once.

More about these formats

Where these figures come from

The claims this page makes about GIF and WebM are checkable, and these are the documents that settle them.