User Rating 0.0 β˜…β˜…β˜…β˜…β˜…
Total Usage 0 times
Drop a .txt file with Base64 data here or click to browse
Is this tool helpful?

Your feedback helps us improve.

β˜… β˜… β˜… β˜… β˜…

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.

base64 to gif base64 decoder gif converter base64 image decode base64 gif download image converter

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:

Lencoded = 4 β‹… ceil(Lbytes3)

Inversely, the decoded byte count from a Base64 string of length Lb64 with p padding characters:

Lbytes = 3 β‹… Lb644 βˆ’ p

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:

width = byte[6] + byte[7] Γ— 256
height = byte[8] + byte[9] Γ— 256

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:

GCTsize = 3 Γ— 2(n + 1) bytes

Where n = value of bits 0 - 2 of the packed field (range 0 - 7).

Reference Data

PropertyGIF87aGIF89aNotes
Year Introduced19871989CompuServe specification
Magic Bytes47 49 46 38 37 6147 49 46 38 39 61First 6 bytes of file
Max Colors256256Per frame, indexed palette
TransparencyNoYesVia Graphic Control Extension
AnimationNoYesMultiple image blocks with delay
Max Dimensions65535 Γ— 65535 px65535 Γ— 65535 px16-bit unsigned integers
CompressionLZW (Lempel-Ziv-Welch)Variable code size 2 - 12 bits
InterlacingYesYes4-pass progressive rendering
Comment ExtensionNoYesBlock type 0x21FE
Application ExtensionNoYesNETSCAPE2.0 for loop control
Trailer Byte0x3B0x3BMarks end of GIF stream
MIME Typeimage/gifRFC 2045 / RFC 2046
Base64 Size Ratio1.33Γ— original4 chars per 3 bytes
Data URI Prefixdata:image/gif;base64,Optional; stripped by this tool
Padding Characters= or ==Aligns to 4-char boundary
Valid Base64 Chars64 symbols + padA - Z, a - z, 0 - 9, +, /
Browser SupportUniversalAll modern browsers decode natively
Color Table Size2n+1 entriesn from packed byte bits 0 - 2
Typical Use CasesAnimations, icons, simple graphicsNot suitable for photographs

Frequently Asked Questions

Common causes include embedded line breaks (MIME-wrapped Base64 uses 76-character lines with CRLF), invisible Unicode characters (zero-width spaces from copy-paste), or a data URI prefix that was not stripped. This tool automatically removes whitespace, newlines, and the data:image/gif;base64, prefix. If the string still fails, verify its length is divisible by 4 after cleanup. An incorrect length indicates truncation during transfer.
This tool checks the first 6 bytes of the decoded binary against the GIF87a and GIF89a magic signatures. A JPEG would begin with bytes FF D8 FF, and a PNG with 89 50 4E 47. If someone Base64-encoded a JPEG and labeled it as GIF, this tool will reject it at the signature verification step and report the actual file type detected.
The practical limit is approximately 10 MB of decoded data, which corresponds to roughly 13.3 MB of Base64 text. This constraint comes from browser memory allocation for the atob() function and Blob construction. For very large animated GIFs exceeding this limit, consider server-side decoding. Most embedded Base64 GIFs in CSS or HTML are under 100 KB, well within this range.
Standard Base64 (RFC 4648 Β§4) uses + and / as characters 62 and 63, with = for padding. Base64url (RFC 4648 Β§5) replaces + with - and / with _ to be URL-safe, and often omits padding. If your string contains - or _ characters, it is likely Base64url-encoded. You must replace - with + and _ with / before this tool can decode it correctly.
This tool parses the GIF binary to count the number of frames and reports it in the metadata. However, full frame-by-frame extraction requires decoding LZW-compressed image data for each sub-image block, handling disposal methods, and compositing against the canvas state. The preview displays the animated GIF natively via the browser's built-in GIF renderer, showing all frames in sequence.
The decoded file size equals (3 Γ— L_b64 / 4) βˆ’ p bytes, where p is the number of = padding characters. If whitespace or line breaks were present in the input, they inflate the apparent string length without contributing to the decoded output. This tool strips all non-Base64 characters before calculating the true decoded size.