Base64 to GIF Converter
Convert Base64-encoded strings to GIF image files instantly. Decode, preview, and download GIF images from Base64 data with validation.
About
Base64 encoding inflates binary data by approximately 33%, representing every 3 bytes as 4 ASCII characters from a 64-character alphabet. Embedded Base64 GIFs in HTML or CSS bypass additional HTTP requests but increase document payload. Incorrect decoding, truncated strings, or data URI prefix remnants produce corrupt files that fail silently in most viewers. This tool validates the GIF89a/GIF87a signature at the binary level before generating a downloadable file.
The converter strips optional data:image/gif;base64, prefixes automatically, checks character legality against the Base64 alphabet (A - Z, a - z, 0 - 9, +, /, =), and parses the Logical Screen Descriptor to extract frame dimensions and color table metadata. If the decoded bytes do not begin with a valid GIF signature, conversion is rejected before any file is created. Note: this tool handles standard Base64 encoding. Base64url variants (using - and _) require character substitution before input.
Formulas
The Base64 encoding maps every group of 3 input bytes to 4 output characters. The encoded length relates to the original binary size as follows:
Inversely, the decoded byte count from a Base64 string of length Lb64 with p padding characters:
Where Lb64 = length of the Base64 string (excluding whitespace), p = number of trailing = padding characters (0, 1, or 2), and Lbytes = decoded binary length in bytes.
GIF dimensions are extracted from the Logical Screen Descriptor at byte offsets 6 - 9 as little-endian 16-bit unsigned integers:
The Global Color Table size is determined from bit 7 (presence flag) and bits 0 - 2 (size exponent) of the packed byte at offset 10:
Where n = value of bits 0 - 2 of the packed field (range 0 - 7).
Reference Data
| Property | GIF87a | GIF89a | Notes |
|---|---|---|---|
| Year Introduced | 1987 | 1989 | CompuServe specification |
| Magic Bytes | 47 49 46 38 37 61 | 47 49 46 38 39 61 | First 6 bytes of file |
| Max Colors | 256 | 256 | Per frame, indexed palette |
| Transparency | No | Yes | Via Graphic Control Extension |
| Animation | No | Yes | Multiple image blocks with delay |
| Max Dimensions | 65535 Γ 65535 px | 65535 Γ 65535 px | 16-bit unsigned integers |
| Compression | LZW (Lempel-Ziv-Welch) | Variable code size 2 - 12 bits | |
| Interlacing | Yes | Yes | 4-pass progressive rendering |
| Comment Extension | No | Yes | Block type 0x21FE |
| Application Extension | No | Yes | NETSCAPE2.0 for loop control |
| Trailer Byte | 0x3B | 0x3B | Marks end of GIF stream |
| MIME Type | image/gif | RFC 2045 / RFC 2046 | |
| Base64 Size Ratio | 1.33Γ original | 4 chars per 3 bytes | |
| Data URI Prefix | data:image/gif;base64, | Optional; stripped by this tool | |
| Padding Characters | = or == | Aligns to 4-char boundary | |
| Valid Base64 Chars | 64 symbols + pad | A - Z, a - z, 0 - 9, +, / | |
| Browser Support | Universal | All modern browsers decode natively | |
| Color Table Size | 2n+1 entries | n from packed byte bits 0 - 2 | |
| Typical Use Cases | Animations, icons, simple graphics | Not suitable for photographs | |