A virtual teacher who reveals to you the great secrets of Base64

PNG to Base64

Convert PNG to Base64 online and use it as a generator, which provides ready-made examples for data URI, img src, CSS background-url, and others. The PNG to Base64 converter is identical to Image to Base64, with the only difference that it forces the mime type to be “image/png” (even if the uploaded file has a different content type or it cannot be detected). Please note that the PNG to Base64 encoder accepts any images types with a size of up to 50 MB. If you are looking for the reverse process, check Base64 to PNG.


How to convert PNG to Base64 online

  1. Choose the source of image from the “Datatype” field.
  2. Paste the URL or select a PNG image from your computer.
  3. If necessary, select the desired output format.
  4. Press the “Encode PNG to Base64” button.
  5. Download or copy the result from the “Base64” field.

About PNG

  • Name: Portable Network Graphics
  • Developer: PNG Development Group
  • MIME types: image/png
  • File Extensions: .png
  • Uniform Type Identifier: public.png
  • Type of Format: Lossless bitmap image

Output formats

If you do not know what output format you need, check the following examples to see how will look the result of the same Base64-encoded PNG image formatted in each of the available formats (as an example image I use a one-pixel red dot PNG file):

Plain text:
iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR42mP4z8AAAAMBAQD3A0FDAAAAAElFTkSuQmCC
Data URI:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR42mP4z8AAAAMBAQD3A0FDAAAAAElFTkSuQmCC
CSS Background Image:
.base64 {
  background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR42mP4z8AAAAMBAQD3A0FDAAAAAElFTkSuQmCC")
}
HTML Favicon:
<link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR42mP4z8AAAAMBAQD3A0FDAAAAAElFTkSuQmCC" />
HTML Hyperlink:
<a href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR42mP4z8AAAAMBAQD3A0FDAAAAAElFTkSuQmCC"></a>
HTML Image:
<img alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR42mP4z8AAAAMBAQD3A0FDAAAAAElFTkSuQmCC" />
HTML Iframe:
<iframe src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR42mP4z8AAAAMBAQD3A0FDAAAAAElFTkSuQmCC">
  The “iframe” tag is not supported by your browser.
</iframe>
JavaScript Image:
var img = new Image();
img.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR42mP4z8AAAAMBAQD3A0FDAAAAAElFTkSuQmCC";
document.body.appendChild(img);
JavaScript Popup:
window.onclick = function () {
  this.open("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR42mP4z8AAAAMBAQD3A0FDAAAAAElFTkSuQmCC");
};
JSON:
{
  "image": {
    "mime": "image/png",
    "data": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR42mP4z8AAAAMBAQD3A0FDAAAAAElFTkSuQmCC"
  }
}
XML:
<?xml version="1.0" encoding="UTF-8"?>
<root>
  <image mime="image/png">iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR42mP4z8AAAAMBAQD3A0FDAAAAAElFTkSuQmCC</image>
</root>

If I missed an important output format for Base64-encoded PNG images, please let me know — I would love to implement it.

Comments (19)

I hope you enjoy this discussion. In any case, I ask you to join it.

  • AngryTooOfDoom,
    this is exllent
  • Santiago,
    I want to send emails from excel with a macro using an outlook account. I want to put one Base64 image on my email but...It's impossible. Instead of the image into the email there is a square with a red x inside. I start writing the macro lilke this:

    MensajeHTML = MensajeHTML & "<img src=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAARsAAABUCAIAAAA9NgR7AAAACXBIWXMAAAsTAAALEwEAmp"
    MensajeHTML = MensajeHTML & "wYAAAAIGNIUk0AAHolAACAgwAA+f8AAIDoAABSCAABFVgAADqXAAAXb9daH5AAADKrSURBVHja7H15mB1Vmfd7zqn1rn"
    MensajeHTML = MensajeHTML & "1v73unsyedPRBCAgFkky2yQ1gUFRF0ZtxlHD9RZxyHcb7xm1FBHQSEAQSCIiqKIvu+hiSkk973/e5LLWf7/qjuTshGQro7xOf+ni"
    ...... this continues with all the data collected from the Base64 field on this page till the last line wich is:
    MensajeHTML = MensajeHTML & "ToFRBXwoSDW+uh2CY70haYFRBRQwlSi0+S6ggAKjCiigwKgCCigwqoACCigwqoACjh7+/wCoanLFlsvTqgAAAABJRU5ErkJggg== />"


    It's impossible to see the image on my email!

    Can you help me please??
    • Javeed,
      src=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAARsAAABUCAIAAAA9NgR7AAAACXBIWXMAAAsTAAALEwEAmp

      Please not find my code
  • Wally,
    Hello. I can see you. Can you see me?
    • abc,
      YES
      i can see you
      • Tony,
        bruh yer message is weird
        • Seer,
          You... you don't see us. You're different.
    • Jesper,
      Yes I can see you.
      Welcome home Wally.
  • Tony,
    hi i dont see the email
  • ari,
    Thanks. This is great
    • Someone,
      No problem, everything for you dear
  • gkk,

    <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACB0lEQVQ4jY2TTUhUURTHf+fy/HrjhNEX2KRGiyIXg8xgSURuokXLxFW0qDTaSQupkHlo6yMijY0UYkGxUKSJFkoxGxRijcZKJDMYHn7f3nvv4+Nx7o18Dw7n3HPO+c///J1AIpFg6vE4juM4juM4DofDmXw+T6FQ6Pf7hUKhwWKxwGw2w+VyQafTQafTgeM4juM4juM4DofDmXw+T6FQ6Pf7hUKhwWKxwGw2w+VyQafTQafTgeM4juM4juM4DofDmXw+T6FQ6Pf7hUKhwWKxwGw2w+VyQafTQafTgeM4juM4juM4DofDmXw+T6FQ6Pf7hUKhwWKxwGw2w+VyQafTQafTgeM4juM4juM4DofDmXw+T6FQ6Pf7hUKhwWKxwGw2w+VyQafTQafTgeM4juM4juM4DofDmXw+T6FQ6Pf7hUKhwWKxwGw2w+VyQafTQafTgeM4juM4juN4nud5nmcymUzK5XKK5/NJp9NJp9PhOA6HwyGXy0Wj0UCj0UCj0eA4Ho/HMZ/PJZ/Po1AooNfrIZ/PI5/PI5/Ph+A63L/friAIgl6vx9lsNpvNJnw+H8dxHMdxHMdx/Bb/g8FgkGAwiCAIgiAIgiAIgiAIgiAIgiAIgiAIgiAIgiAIgiAIgiAIgiAIgiAIgiAIgiAIgiAIAv8Bb3hDuJh/1TkAAAAASUVORK5CYII=" onerror="alert('XSS')">


    This XSS attack vector uses a data URI scheme to embed a PNG image into the src attribute of an <img> tag. The image looks like a cat to humans, but it contains a hidden text that says “alert(‘XSS’)”. The text is encoded in a way that is invisible to humans, but recognizable by an AI system that uses optical character recognition (OCR) or natural language processing (NLP). The onerror attribute of the <img> tag executes JavaScript code when the image fails to load. The code displays an alert box with the message ‘XSS’.

    This XSS attack vector can trick an AI system that scans or analyzes images on web pages, such as a web crawler, a search engine, a content filter, a translator, etc. The AI system may try to extract or process the text from the image, and end up executing the
  • sengngorn,
    I want to learn how to convert Images and can view them in power.
  • tomy,
    Yes problem, everything for you dear
  • nqhXncMU,
    -5 OR 66=(SELECT 66 FROM PG_SLEEP(15))--
    • Joe_Biden,
      bro tried sql injecting ???
  • nqhXncMU,
    0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
  • ISEEYOU,
    I WILL KILL YOU ALL
  • dunno,
    this comment section is weird
Add new comment

If you have any questions, remarks, need help, or just like this page, please feel free to let me know by leaving a comment using the form bellow.
I will be happy to read every comment and, if necessary, I will do my best to respond as quickly as possible. Of course, spammers are welcome only as readers.