PNG to Base64 Converter (PNG to Base 64)
Convert PNG to Base64—or, in the spaced spelling, PNG to Base 64—and instantly copy the raw string, complete data URI, HTML or CSS. Transparency stays intact.
100% client-side. Your PNG never leaves your device.
Drop a PNG to convert it to Base64
or paste from your clipboard · transparency is preserved
How to convert PNG to Base64 (Base 64)
A PNG is a binary image file. Base64 rewrites those bytes as text characters that can travel inside HTML,
CSS, JavaScript, JSON or another text-only format. This converter performs that rewrite locally and returns
both the encoded string and a complete data:image/png;base64, URI. The spaced phrase
“PNG to Base 64” describes exactly the same conversion; Base64 is the standard spelling.
- Add a PNG. Drag the file onto the converter, choose it from your device, or paste it from the clipboard.
- Review the result. The page shows the file type, original size, Base64 length and a local preview.
- Copy the format you need. Choose the full data URI, raw Base64 body, HTML
<img>snippet or CSS declaration. - Paste and test. Add the result to your code and verify it in the browser where it will be used.
Raw Base64 string vs PNG data URI
The raw Base64 string contains only encoded PNG data. It commonly begins with
iVBORw0KGgo, which represents the PNG file signature. A data URI adds the MIME-type
prefix data:image/png;base64, before that string. Browsers need the prefix when you place the
result directly in an image source or CSS rule; APIs and databases sometimes request only the raw body.
Use the format required by the destination instead of removing the prefix by guesswork.
Transparency is preserved
Base64 encoding is lossless: it changes how the bytes are represented, not the image itself. The PNG color data, dimensions and alpha channel remain unchanged. When a browser decodes the data URI, transparent pixels are still transparent and hard edges remain crisp. The conversion does not compress, resize, recolor or convert the PNG to another image format.
Use PNG Base64 in HTML, CSS and JavaScript
For HTML and CSS, copy the complete data URI so the browser knows both the media type and encoding. Keep a
useful alt description on meaningful HTML images. In JavaScript, the same URI can be assigned to
an image source or stored with a component that needs a self-contained asset.
<!-- HTML -->
<img src="data:image/png;base64,iVBORw0KGgo..." alt="Product logo" width="32" height="32" />
/* CSS */
.icon { background-image: url(data:image/png;base64,iVBORw0KGgo...); }
// JavaScript
const iconDataUri = "data:image/png;base64,iVBORw0KGgo...";
document.querySelector(".preview").src = iconDataUri;
Use raw PNG Base64 in JSON or an API
Some APIs accept an entire data URI, while others define a separate MIME-type field and expect only the raw
Base64 value. Check the API contract before sending the request. If the schema has fields such as
media_type and data, use image/png for the first and the prefix-free string
for the second. Base64 is text-safe, but it is still large, so validate request-size limits before including
a high-resolution screenshot or export.
When to inline a PNG
- Small interface assets: a compact icon, badge, spinner or logo where avoiding another request is useful.
- Portable documents: a self-contained HTML report, demo or email template that must travel as one file.
- Prototypes and test fixtures: temporary code that should work without an image host or extra project asset.
- Text-only storage: a system that accepts strings but cannot receive a separate binary upload.
Inline only when portability or fewer requests is worth the extra bytes. For a normal production website, an optimized image file is often easier to cache, replace and deliver through a CDN.
When a normal PNG file is better
Keep large screenshots, photos and hero graphics as regular files. Base64 encoding adds roughly one third to the binary size before compression, and an inline image cannot be cached independently from the HTML or CSS that contains it. Reusing the same long data URI across several pages also repeats bytes that a separately hosted PNG could download once. Normal files are usually better for responsive images, lazy loading, CDN resizing and content that changes frequently.
Why Base64 output is larger
Base64 represents every three input bytes with four text characters, so the encoded body is about 33% larger than the original PNG. The short data-URI prefix adds a few more characters. HTTP compression may reduce the transfer difference when the string is embedded in a compressed HTML or CSS file, but it does not remove the browser's decode work or restore independent caching. Compare the final compressed page size rather than assuming every inline image improves performance.
Private, browser-only conversion
The converter uses the browser's FileReader API. Your PNG is read on the current device and the
result is written into the output fields; the file is not uploaded to this site. That makes the tool suitable
for internal screenshots and design assets, although you should still avoid pasting a sensitive result into
third-party forms, public issue trackers or source code that will be published.
Troubleshooting PNG Base64 output
- The browser shows a broken image: use the full data URI and make sure there is no whitespace inside the prefix.
- An API rejects the value: confirm whether it wants raw Base64 or the complete
data:image/png;base64,form. - The result is unexpectedly long: check the original PNG dimensions and optimize the file before encoding it.
- Transparency looks wrong: verify the destination supports PNG alpha and has not converted the output to JPEG.
- Copying was incomplete: use the Copy button rather than manually selecting part of a long output field.
Security note for Base64 images
Base64 is an encoding, not encryption. Anyone who receives the string can decode the original PNG. Treat the output with the same care as the source file, and do not use encoding as a way to hide confidential content. If you accept Base64 from other users in an application, validate the declared MIME type, decoded size and file signature before storing or displaying it.
More Base64 converters
Frequently asked questions
Does converting PNG to Base64 keep transparency?
Yes. Base64 is lossless — it stores the exact bytes of your PNG including the alpha channel, so the decoded image is pixel-for-pixel identical and transparent areas stay transparent.
What does a PNG Base64 string start with?
A PNG data URI starts with data:image/png;base64, and the encoded body almost always begins with iVBORw0KGgo — the Base64 signature of the PNG header.
Is the PNG to Base64 conversion private?
Yes. Everything runs in your browser with the FileReader API. The PNG is never uploaded to any server.
Is PNG to Base 64 different from PNG to Base64?
No. “PNG to Base 64” is simply a spaced spelling of “PNG to Base64.” Both refer to encoding the same PNG file bytes with the Base64 format.
When should I avoid embedding a PNG as Base64?
Avoid inlining large PNG files or images reused on many pages. Base64 adds about 33% to the file size, while a normal image URL can be cached independently by the browser.
Can I use a PNG Base64 data URI in HTML and CSS?
Yes. Put the complete data URI in an HTML img src attribute or inside CSS url(). It starts with data:image/png;base64, followed by the encoded PNG data.