User Rating 0.0
Total Usage 0 times
0 characters
Is this tool helpful?

Your feedback helps us improve.

About

Data URIs embed images directly in HTML/CSS as base64-encoded strings, eliminating HTTP requests but increasing document size by approximately 33%. This converter extracts the binary image data from URIs following RFC 2397 specification, validating the MIME type header and base64 padding. Malformed URIs lacking proper data: prefix or containing invalid base64 characters will fail decoding, potentially breaking production deployments. The tool handles standard formats: PNG, JPEG, GIF, WebP, SVG, and BMP.

Base64 encoding maps binary data to 64 ASCII characters using AZ, az, 09, +, / alphabet. Each 3 bytes become 4 characters, with = padding for incomplete triplets. Modern browsers limit Data URI size to 2MB in attributes, though this varies. CSS implementations may accept larger values.

base64 data-uri image converter decoder

Formulas

Data URI structure follows the RFC 2397 format:

data:[mediatype][;base64],data

File size calculation from base64 string:

Sbytes = Lbase64 × 34 P

where Lbase64 = length of base64 string, P = padding count (number of = characters)

Encoding efficiency ratio:

E = SencodedSoriginal 1.33

Reference Data

FormatMIME TypeMagic Bytes (Hex)Max ColorsTransparencyCompression
PNGimage/png89 50 4E 4716.7M (24-bit)Alpha channelLossless (DEFLATE)
JPEGimage/jpegFF D8 FF16.7M (24-bit)NoneLossy (DCT)
GIFimage/gif47 49 46 38256 (8-bit)Binary (1-bit)Lossless (LZW)
WebPimage/webp52 49 46 4616.7M (24-bit)Alpha channelBoth modes
SVGimage/svg+xml3C 73 76 67UnlimitedNativeText (GZIP)
BMPimage/bmp42 4D16.7M (24-bit)Optional (32-bit)None (raw)
ICOimage/x-icon00 00 01 0016.7M (24-bit)Alpha channelNone/PNG
AVIFimage/avif00 00 00 2010-bit/12-bitAlpha channelLossy (AV1)
TIFFimage/tiff49 49 2A 0048-bitAlpha channelMultiple
WebP Animimage/webp52 49 46 4616.7M (24-bit)Alpha channelVP8/VP8L

Frequently Asked Questions

Common issues include missing "data:" prefix, incorrect MIME type syntax (must be 'image/type'), whitespace contamination, or improper base64 padding. The base64 alphabet only accepts A-Z, a-z, 0-9, +, / characters plus = for padding. Line breaks within the encoded data will cause failures. Verify the string length is divisible by 4 after removing the header.
Chrome and Firefox limit Data URIs to approximately 2MB when used in src attributes. Internet Explorer historically capped at 32KB. CSS url() declarations may accept up to 4MB. Mobile browsers often impose stricter limits around 512KB. Exceeding limits triggers silent failures or ERR_INVALID_URL errors.
Data URIs increase HTML/CSS size by 33% due to base64 overhead. Only embed images under 5KB to avoid render blocking. Use WebP format for 25-35% smaller file sizes. Enable GZIP compression which reduces base64 strings by 15-20%. Consider lazy loading for non-critical images. Monitor Total Blocking Time metrics.
Yes, base64 encoding preserves all binary data including EXIF, ICC profiles, and XMP metadata. This often bloats URIs unnecessarily. Strip metadata before encoding using tools like ImageOptim. PNG gamma chunks and JPEG APP segments remain intact, potentially causing color shifts across browsers.
Animated formats encode all frames within the base64 string. A 500KB animated GIF becomes a 667KB Data URI. Browser memory usage spikes as each instance creates a separate decode buffer. Chrome limits animated Data URIs to 10MB decoded size. Performance degrades exponentially with multiple animated URIs on the same page.