PNG to Base64
Encode a PNG to Base64 with transparency intact — free, instant, nothing uploaded
Upload PNG
Drag & drop or click to upload
PNG, including PNG-8 and animated APNG
Includes the MIME type prefix — paste straight into an HTML or CSS src
Upload a file to see the Base64 output…The string only, no prefix — for APIs and databases that add their own header
Upload a file to see the Base64 output…A finished CSS rule, ready to paste into a stylesheet
Upload a file to see the Base64 output…Copy this straight into your markup
Upload a file to see the Base64 output…Transparency Survives. That Is the Whole Point.
You encode a logo, paste it into your CSS, and it arrives sitting on a white rectangle. The cut-out edge is gone and the design looks broken. That happens when a converter quietly re-saves your file as JPEG. This PNG to Base64 tool never touches your pixels.
We read the file byte for byte, so the alpha channel arrives exactly as it left. Drop a PNG in and the four outputs are ready before you finish reading this sentence.
How to Convert a PNG to Base64 String Output
- Optimise first, if you can. A pass through pngquant or oxipng often halves the file.
- Drop the PNG in. Drag it onto the box or click to browse.
- Check the growth number. The panel shows exactly how much bigger the encoding made it.
- Copy the format you need. Data URL, raw string, CSS rule, or HTML tag.
That first step matters more than people expect. Optimisation before encoding is the highest-leverage thing you can do here, because every byte you remove saves roughly 1.33 bytes in the output.
Why PNG to Base64 Keeps the Alpha Channel
PNG stores transparency in a fourth channel alongside red, green, and blue. Every pixel carries an opacity value from fully clear to fully solid.
Base64 is not an image operation at all. It rewrites bytes as text characters, three bytes at a time, and knows nothing about pixels. Because we hand it the original file, the alpha data passes through untouched.
The tools that break transparency do so earlier in the chain. They load your PNG into a canvas element, then export it — and if the export format is JPEG, the alpha channel has nowhere to go. We skip the canvas entirely.
Encoding a photograph instead? A JPG to Base64 converter will give you a far shorter string for the same picture.
Using a PNG Data URL in CSS
The CSS output is a complete declaration. Paste it inside any rule:
.logo {
background-image: url("data:image/png;base64,iVBORw0KGgoAAA...");
background-size: contain;
background-repeat: no-repeat;
}Inlining like this removes one network request. For an icon that appears on every page, that is a real win on first load.
Here is the downside we always flag: a stylesheet is render-blocking. Every visitor waits for the whole file, including your Base64 payload, before anything paints. Inline small assets only — under a few kilobytes is the sensible ceiling.
Our guide to inline images in CSS and HTML covers the caching trade-off in full.
When PNG Is the Wrong Format to Encode
Three cases where we would tell you to stop and pick something else:
- Photographs. PNG stores every pixel losslessly, so a camera image balloons. JPEG or WebP will be dramatically smaller.
- Flat vector artwork. If the original is an icon set or a logo drawn in vector, encode the SVG instead — see the SVG to Base64 encoder.
- Large hero images. Anything above roughly 10 KB belongs on a CDN with cache headers, not inline.
If the source is the wrong format, convert it before encoding rather than after. Our image format converter handles PNG to WebP, JPEG, and AVIF.
Going Backwards From a String
Already holding an encoded PNG and need the file? The Base64 to PNG decoder takes the string and gives you a downloadable image.
It works even when the data: header is missing, because a PNG payload always begins with the characters iVBORw0KGgo. That signature is enough to identify the format.
For mixed formats, the general image to Base64 converter accepts anything your browser can read.
Frequently Asked Questions
Does encoding a PNG keep the transparent background?
+
Why is my PNG string so much longer than a JPEG of the same photo?
+
Can I encode an 8-bit indexed PNG, sometimes called PNG-8?
+
What happens to an animated PNG, or APNG?
+
My transparent PNG shows a black box in some email clients. Why?
+
Are text chunks inside the PNG, like copyright or software tags, preserved?
+
Should I compress the PNG before converting it?
+
Why is my screenshot such a large PNG?
+
Can I use a Base64 PNG as a favicon?
+
Will the same PNG always produce the same Base64 string?
+
The Short Version
Optimise the file, drop it in, copy the output. Converting PNG to Base64 preserves transparency here because nothing re-compresses your image along the way.
Keep it to small assets. Icons and logos inline beautifully; photographs and hero images do not.
Related Tools You Might Like
YAML Creator & Validator
Create, validate, and generate YAML files with predefined templates for deployment configurations
JWT Decoder
Decode and inspect JSON Web Tokens — view header, payload, and expiration
Markdown Editor
Write and preview Markdown with live rendering, toolbar, and export options
IP Lookup
Look up IP address geolocation, ISP, timezone, and network details
Caesar Cipher & ROT13 Decoder
Classical ciphers and encodings: Caesar, ROT13, XOR, Base64, hex, Morse
Hash Generator
Generate MD5, SHA-1, SHA-256, SHA-384, and SHA-512 hashes for text and files
