Most "free GIF converter" sites ask you to upload a clip and wait out a spinner. I didn't want that for TinyGIF. The tools should shrink and convert GIFs so they pass a platform limit — a Discord emoji, a chat upload, a Twitch emote — without the file ever leaving the device.
I'm Danny, and I built TinyGIF. The interesting problem wasn't "can FFmpeg run in a tab?" The ffmpeg.wasm project already answered that. It was this: the single-thread @ffmpeg/core build we ship is 30.7 MiB, and Cloudflare Workers rejects any one static asset larger than 25 MiB. Here's how that Wasm file is cut into pieces, fetched in parallel, and glued back into a module the browser can compile.
Why do this in the browser?
Three reasons, all from the same decision.
Privacy. The file is read from disk, processed in memory, and offered back as a download. TinyGIF's about page puts it plainly: there is no server that could receive the file. Close the tab and it's gone.
Cost. A transcode farm is a per-file bill. Because the heavy work runs on the visitor's machine, there is no server-side encode to pass on, which is why the tools can stay free, with no account, no watermark and no daily cap.
Honest limits. Discord, Twitch and Kick publish specific byte and pixel rules, and they don't all mean the same thing by "KB" or "MB". Once the work is in the browser, the same page can encode the file and check it against a sourced, dated table before you download.
The trade-off is real: the first FFmpeg conversion has to download the converter, and phones have less memory than desktops. The site shows a progress bar for that first load (it happens once) and tells you when a file is too big for the device instead of freezing.
Two Wasm engines, not one
It's tempting to say "we compress GIFs with ffmpeg.wasm." That isn't quite right, and the distinction matters if you're building something similar.
Existing GIFs are compressed with gifsicle, compiled to WebAssembly from gifsicle 1.96.4 (gifsicle-wasm) and run in the browser with command-line arguments. The GIF compressor walks a fixed sequence and stops as soon as the file fits: lossless frame-differencing first, then stepped lossy compression, fewer colours, fewer frames, and only then smaller dimensions.
Video becomes a GIF with FFmpeg. The video to GIF converter uses @ffmpeg/core 0.12.10, the single-thread build, in a Web Worker. It accepts MP4, WebM and MOV, lets you trim a range, pick a width and frame rate, and builds a 256-colour palette from the clip before rendering. If the result is still over a Discord limit, "Make it smaller" runs the same gifsicle compressor on the output — still in the tab.
The licences page lists versions and GPL obligations. The rest of this article is about getting that FFmpeg core onto the edge.
The 25 MiB wall
TinyGIF is a static Astro site served as Cloudflare Workers static assets: HTML and hashed files at the edge, and the visitor's browser does the transcode.
It also has a hard cap. Cloudflare's docs list Individual Static Asset file size: 25 MiB on both the free and paid Workers plans (25 MiB is 26,214,400 bytes). A single ffmpeg-core.wasm drop-in does not fit.
The core TinyGIF actually ships is 32,232,419 bytes, about 30.7 MiB. That figure comes from the live converter manifest at /ffmpeg/manifest.json, which also records the package version (0.12.10) and a short content hash.
Split the binary, fetch the parts in parallel, glue them back
At build time the Wasm file is cut into parts, each safely under 25 MiB. At run time the browser downloads every part, concatenates them in order, and compiles the result as application/wasm.
Today the live manifest looks like this:
{
"version": "0.12.10",
"hash": "9f57947a5b",
"size": 32232419,
"parts": [
{ "name": "ffmpeg-core.0.12.10.9f57947a5b.0.wasm", "size": 12582912 },
{ "name": "ffmpeg-core.0.12.10.9f57947a5b.1.wasm", "size": 12582912 },
{ "name": "ffmpeg-core.0.12.10.9f57947a5b.2.wasm", "size": 7066595 }
]
}
The first two parts are exactly 12 MiB; the third is the remainder, about 6.74 MiB. Each part is a same-origin static file under /ffmpeg/, served as application/wasm. The hashed names are cached with Cache-Control: public, max-age=31536000, immutable. The manifest itself is revalidated, so a new core can ship without leaving a stale 30 MiB file in the cache.
The loader, in outline — an illustration of the approach, not a paste of the production module — reads the manifest, fetches every part at once, rejects a part whose length doesn't match, and builds a Blob the Wasm compiler will accept.
// Illustration of the approach, not a copy of production code.
async function loadCoreWasm(manifestUrl, onProgress) {
const manifest = await fetch(manifestUrl).then((r) => {
if (!r.ok) throw new Error(`HTTP ${r.status} for ${manifestUrl}`);
return r.json();
});
const base = new URL(".", new URL(manifestUrl, location.href));
let loaded = 0;
onProgress?.(0, manifest.size);
const parts = await Promise.all(
manifest.parts.map(async (part) => {
const res = await fetch(new URL(part.name, base));
if (!res.ok) throw new Error(`HTTP ${res.status} for ${part.name}`);
// Production streams the body so the progress bar moves as
// bytes arrive; a single arrayBuffer() is the same idea.
const buffer = await res.arrayBuffer();
if (buffer.byteLength !== part.size) {
throw new Error(
`${part.name} was ${buffer.byteLength} bytes, expected ${part.size}`
);
}
loaded += buffer.byteLength;
onProgress?.(loaded, manifest.size);
return buffer;
})
);
// Promise.all keeps parts in manifest order, which matters here.
return new Blob(parts, { type: "application/wasm" });
}
const blob = await loadCoreWasm("/ffmpeg/manifest.json", onProgress);
const module = await (typeof WebAssembly.compileStreaming === "function"
? WebAssembly.compileStreaming(
new Response(blob, { headers: { "Content-Type": "application/wasm" } })
)
: WebAssembly.compile(await blob.arrayBuffer()));
A few details that are easy to skip:
-
Validate the manifest. Check that
partsis non-empty, that eachnameis a simple filename (no path segments), and that the part sizes sum tosize. A truncated part should fail clearly, not as a Wasm magic-number error. - Don't start FFmpeg on page load. The first conversion triggers the download; later ones reuse the compiled module.
- Encode in a Worker. TinyGIF uses the single-thread core in a module Worker, so the tab stays responsive and you don't need cross-origin isolation just to get a GIF out. The video tool's copy describes it as needing no special browser features.
-
Keep the encode command ordinary. Palette-based GIF conversion — trim, fps, scale,
palettegen/paletteuse— is regular FFmpeg; ffmpeg.wasm just takes those arguments in the Worker. The snippet below is the shape of the call, not a dump of production flags:
// Typical ffmpeg.wasm usage, not TinyGIF's exact production command.
await ffmpeg.writeFile("input.mp4", fileBytes);
await ffmpeg.exec([
"-ss", "0",
"-t", "3",
"-i", "input.mp4",
"-vf", "fps=10,scale=480:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse",
"out.gif",
]);
const data = await ffmpeg.readFile("out.gif");
Aim at the limit the platform actually enforces
A converter that only dumps a GIF is half a product. The other half is knowing whether Discord will accept it.
Limits on TinyGIF come from one data file, each with a source link and a last-checked date, rechecked every quarter. When two official pages disagree, the UI says so. A few figures people trip over, as shown on the site:
- Discord custom emoji: under 256 KB, uploaded at up to 128×128 (last checked 2026-10-16). The developer docs write that budget as 256 KiB.
- Discord chat upload: under 20 MB for free accounts as of August 2026 (last checked 2026-11-12). Nitro Basic and server Boost Level 2 raise that to 50 MB; full Nitro is 1 GB; Boost Level 3 is 100 MB.
- Twitch animated emotes (auto-scaling): up to 1 MB, at most 60 frames (last checked 2026-10-23).
The tools treat KB and MB as 1024-based (256 KB = 262,144 bytes) and aim about 3 percent under the stated limit. Platforms rarely say whether they mean 1000 or 1024, and a file that only just fits one reading can fail the other. The Discord GIF compressor turns those rules into presets — emoji, sticker, avatar, server avatar, banner, chat — and shows a pass/fail badge on the result.
Try it
To see the loader happen, open the video to GIF converter, drop in a short MP4, WebM or MOV, and watch the first-run "Loading converter…" bar. That's the three Wasm parts arriving in parallel. Trim a few seconds, pick a Discord preset if you need one, and download the GIF — nothing is uploaded.
If you already have a GIF, skip FFmpeg and use the GIF compressor or the Discord presets above. Both run gifsicle in the browser.
FFmpeg and gifsicle are GPL-licensed; versions and corresponding source are on the licences page. If you're hitting the same 25 MiB wall with another Wasm core, splitting it and concatenating in the client is a workable pattern — pin the parts with a hash, and never trust a file whose length doesn't match the manifest.
Top comments (0)