APNG to Base64 Converter
Convert APNG animated images to Base64 encoded strings instantly. Get Data URI, CSS background, or HTML img tag output formats.
About
Base64 encoding inflates file size by approximately 33.3% due to the 3-byte to 4-character mapping ratio. Embedding an APNG animation that weighs 150KB on disk will consume roughly 200KB inside your HTML or CSS. Misusing inline encoding on assets above 50KB degrades page load time and bloats the DOM, which directly harms Core Web Vitals scores. This tool validates the PNG signature header (89 50 4E 47) and confirms the presence of the acTL animation control chunk before encoding, so you never accidentally treat a static PNG as animated or ship a corrupt string to production.
All conversion runs client-side in the browser. No file data leaves your machine. The tool produces four output formats: raw Base64, Data URI with correct image/apng MIME type, a CSS background-image declaration, and an HTML <img> element. Note: browsers that lack APNG support (older IE/Edge) will render only the first frame as a static PNG fallback. Pro tip: for assets under 10KB, inline Base64 eliminates an HTTP request and can improve performance; above that threshold, a separate file with proper caching is almost always faster.
Formulas
Base64 encoding maps every group of 3 input bytes to 4 ASCII characters drawn from a 64-character alphabet (A−Z, a−z, 0−9, +, /). The encoded output length is computed as:
where n = original file size in bytes and Lbase64 = resulting character count. The size inflation ratio is therefore:
For a Data URI, the total payload adds a prefix string of fixed length:
where prefix = data:image/apng;base64, (24 characters). APNG detection relies on scanning PNG chunks. Each chunk has the structure: 4-byte length, 4-byte type, variable data, 4-byte CRC. The presence of a chunk with type bytes 61 63 54 4C (ASCII: acTL) confirms animation capability.
Reference Data
| Property | APNG | GIF | WebP | AVIF |
|---|---|---|---|---|
| Max Colors | 16.7M (24-bit + alpha) | 256 | 16.7M | 16.7M |
| Alpha Channel | 8-bit transparency | 1-bit (on/off) | 8-bit transparency | 8-bit+ transparency |
| Compression | Lossless (deflate) | Lossless (LZW) | Lossy + Lossless | Lossy + Lossless |
| Animation Support | Yes (via acTL/fcTL/fdAT) | Yes (native) | Yes | Yes (AVIF sequence) |
| Browser Support (2024) | 96%+ | 100% | 97%+ | 92%+ |
| Typical File Size (100×100 animation) | 50−200KB | 80−300KB | 30−120KB | 20−80KB |
| MIME Type | image/apng | image/gif | image/webp | image/avif |
| Base64 Size Overhead | ~33.3% | ~33.3% | ~33.3% | ~33.3% |
| PNG Signature (hex) | 89 50 4E 47 0D 0A 1A 0A | |||
| Animation Chunk | acTL (animation control) | Application Extension Block | VP8 bitstream | AVIF ItemProperties |
| Frame Chunk | fcTL (frame control) + fdAT (frame data) | Image Descriptor per frame | ANMF chunk | Sequence items |
| Fallback (no animation support) | Displays default IDAT as static PNG | Shows first frame | Shows first frame | Shows poster frame |
| Max Dimensions | 231−1 px per axis | 65,535 px | 16,383 px | 65,536 px |
| Recommended Max for Base64 Inline | 10KB original → ~13.3KB encoded | |||
| Data URI Prefix | data:image/apng;base64, | data:image/gif;base64, | data:image/webp;base64, | data:image/avif;base64, |
| Spec / Standard | APNG Spec (Mozilla) + PNG ISO/IEC 15948 | GIF89a (CompuServe) | Google/WebM Project | AOM / ISO/IEC 23000-22 |