PNG to Base64

Use this free PNG to Base64 converter to turn any Portable Network Graphics image into a Base64 string or a ready-made code snippet. Select a local .png file (or paste a link to a remote one), pick the output format and press Encode PNG to Base64.

PNG file
Drop your PNG file here or choose one

How to convert PNG to Base64 online

  1. Choose Local file and select a .png file, or choose Remote URL and paste a link.
  2. Select the output format: plain Base64, data URI, HTML tag, CSS, JavaScript, JSON or XML.
  3. Click Encode PNG to Base64. The result appears instantly with a preview.
  4. Copy the result to the clipboard or download it as a .txt file.

About PNG (Portable Network Graphics)

PNG is a lossless raster format created in 1996 as a patent-free replacement for GIF. It supports full 24-bit color, an 8-bit alpha channel for smooth transparency, and DEFLATE compression that never discards pixel data.

Because it keeps edges crisp, PNG is the standard choice for logos, icons, UI screenshots and diagrams. For photographs, JPG or WebP is usually much smaller, which matters when you embed the image as Base64 because every byte grows by about a third.

Developed1996, W3C / IETF (RFC 2083)
CompressionLossless (DEFLATE)
TransparencyYes, full alpha channel
AnimationAPNG extension
File signature89 50 4E 47 0D 0A 1A 0A

Output formats

Choose how the result should be wrapped. The converter can return:

  • txt: only the Base64 string, ready to paste into code, a database field or an API request.
  • uri: a complete data: URI that you can paste in a browser address bar or use anywhere a URL is accepted.
  • html img: an <img> tag with the data URI in src.
  • css background image: a CSS rule using background-image: url(data:...).
  • html favicon: a <link rel="icon"> tag for an inline favicon.
  • html hyperlink: an <a> link that downloads or opens the embedded file.
  • html iframe: an <iframe> that renders the content inline.
  • javascript image: JavaScript that creates an Image object.
  • javascript popup: JavaScript that opens the content in a new window.
  • json: a JSON object with the file name, MIME type and data.
  • xml: an XML element with the data inside a CDATA section.

Is it safe and how large will the result be?

Your file is never uploaded: it is read and converted locally by your browser using the File API, so even confidential documents stay on your device.

Base64 represents every 3 bytes with 4 characters, so the encoded result is about 33% larger than the original file (plus a few bytes for padding and the data URI prefix).

Frequently asked questions

How do I convert PNG to Base64?

Select your .png file above and click "Encode PNG to Base64". The converter reads the file in your browser and outputs the Base64 string or a ready data URI.

What does a Base64-encoded PNG start with?

A PNG file encoded to Base64 typically starts with "iVBORw0KGgo". As a data URI it begins with "data:image/png;base64,".

Is there a file size limit?

There is no hard limit because the conversion runs locally, but very large files produce very long strings. Files up to about 50 MB work comfortably in modern browsers.

How do I convert the Base64 back to PNG?

Use the Base64 to PNG decoder: paste the string, and you can preview and download the original .png file.

Related tools and guides

Comments (0)

Questions, ideas or a bug in “PNG to Base64”? Leave a comment, rate the tool, or reply to others.

No comments yet. Be the first to share your feedback!

Leave a comment

Rate this tool:
Esc
↑ ↓ move↵ openEsc close