Loading Image to Base64 Converter...

How to Convert PNG to Base64 - Step by Step Guide

Step 1

Upload Your PNG Image

Start with your PNG image. Click the "Upload" button or drag the file onto the left panel. Icons, logos, screenshots and UI sprites with see-through backgrounds are the usual candidates.

•
Click to upload: Use the "Upload" button to pick a PNG from your computer or phone
•
Drag and drop: Drop the file straight onto the left panel
•
Try the sample: "Sample" loads a small 32 by 32 PNG so you can see the output before using your own file
•
Size limit: Files up to 10 MB are accepted
•
Stays on your device: The PNG is read by your browser and is not uploaded to a server
Step 2

Check the Preview and the Output

As soon as the file is read, the Base64 encoded string appears on the right. On the left you see the image, its file size and the format detected from the file's first bytes.

•
No button to press: Encoding starts by itself once you pick a file
•
Real format check: A JPEG or GIF saved with a .png name is labelled with its real format and gets a note with the right data URI prefix
•
Plain Base64: Just the encoded characters, with no data:image/png;base64, in front
•
Local processing: The browser's FileReader API reads the file on your device

Understanding Base64 Encoding

What happens to your PNG:

→
Binary to text: every 3 bytes of the file become 4 characters from the RFC 4648 alphabet
→
Size increase: the text ends up about 33% larger than the file
→
Easy to spot: every PNG starts with iVBORw0KGgo once encoded
Step 3

Copy or Download Your Base64 String

"Copy" puts the string on your clipboard and "Download" saves it as a text file. Both hold exactly what you see in the editor.

•
Copy: copies the whole Base64 string in one go
•
Download as file: saves the string as a .txt file named after your image
•
Use in HTML: embed it in <img src="data:image/png;base64,..."> tags
•
CSS backgrounds: use it in CSS background-image for small icons that should arrive with the stylesheet
•
Next image: "Remove" clears the panel so you can pick another PNG

What is PNG to Base64 Conversion?

PNG to Base64 conversion writes the bytes of a Portable Network Graphics file out as plain text, using 64 characters (A-Z, a-z, 0-9, + and /). That text can sit inside HTML, CSS, a JSON payload or an email template where a binary file could not.

PNG compresses without losing detail and can store an alpha channel, which is why it is the usual choice for logos and icons with transparent edges. Because the page encodes the file as it is, none of that changes: decoding the string gives you the same PNG back.

How PNG to Base64 Encoding Works

The browser reads the PNG as a data URL, which is the MIME type (image/png) followed by the Base64-encoded bytes. The page keeps only the part after the comma, so you get the bare string and add the prefix where you need it.

Inline PNGs work best for small things: a favicon in a single-file HTML page, icons inside a stylesheet, a logo in an email signature, or an image field in a JSON API. Big images are better left as separate files, since a long string makes the HTML or CSS heavier and cannot be cached on its own.

Frequently Asked Questions

How do I turn a PNG into Base64?

Click Upload and pick the .png file, or drop it onto the left panel. Once the browser has read it, the Base64 string fills the editor on the right, and Copy or Download gives you exactly that text. To turn a string back into a file later, paste it into Base64 to PNG.

What does a PNG look like once it is encoded?

Every PNG file opens with the same eight bytes (89 50 4E 47 0D 0A 1A 0A), so every PNG string starts with iVBORw0KGgo. Almost all of them go on with iVBORw0KGgoAAAANSUhEUg, because the IHDR header comes right after the signature. If a string you were handed starts with /9j/ it is a JPEG, and R0lGOD means a GIF, whatever the file name said.

Is the transparent background kept?

Yes. The page encodes the file byte for byte and never redraws the image, so the alpha channel, the palette, 16-bit colour depth and any text chunks inside the PNG all end up in the string unchanged. Decode it and you get the identical file back, transparent corners included.

How do I use the string in HTML, CSS or an email?

Put data:image/png;base64, in front of it. In HTML that is <img src="data:image/png;base64,YOUR_STRING" alt="...">, and in CSS background-image: url(data:image/png;base64,YOUR_STRING);. The output panel holds only the Base64 part, so add the prefix yourself. HTML emails take the same data URI, but some mail clients (Gmail, for one) do not show inline data images, so send yourself a test first.

What if my file is not really a PNG?

The format is read from the first bytes of the file, not from its name. A JPEG or GIF saved as .png is still encoded exactly, but it is labelled with its real format and a note tells you which data URI prefix to use instead of data:image/png. A text file or anything else that is not an image is refused with a message.

Why is the Base64 bigger than the PNG?

Base64 writes every 3 bytes as 4 characters, so the text is about a third larger than the file: a 30 KB icon becomes roughly 40 KB of text. That is fine for logos, icons and small UI graphics. For large screenshots or photos a normal image file is better, because the browser can cache it separately. The page accepts files up to 10 MB.

Is my image uploaded anywhere?

No. Your browser reads the PNG and builds the Base64 string on your own device, so the image is not sent to a server and nothing is kept. A reload gives you an empty panel again.

Need the image back? Base64 to PNG turns a string into a .png file again, and Base64 to Image works out the format for you. For JPEG, WebP, GIF or SVG files, use Image to Base64.