How to Convert an Image to a Base64 Certificate for HTML

Sometimes, you may want to embed an image directly into HTML without needing an external file. This can be done by converting the image into a Base64 certificate. Here’s a simple guide to do this using Windows command line and HTML.

Step 1: Convert Your Image to a Certificate

Use the certutil command in Windows to convert your PNG image into a Base64-encoded text file:

certutil -encode image005.png image005.txt
  • image005.png is the original image.
  • image005.txt will be the resulting Base64-encoded file.

This command generates a text file containing your image in Base64 format.


Step 2: Embed the Base64 Certificate in HTML

To display the image directly in a web page, wrap the Base64 content with an <img> tag as follows:

<img src='data:image/png;base64,INSERT_BASE64_CONTENT_HERE'>
  • Replace INSERT_BASE64_CONTENT_HERE with the Base64 string from your image005.txt file.
  • Make sure the <img> tag is complete and the Base64 string is intact.

Example:

<img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAC3CAYAAAA4sY/iAAAAAXNSR0ICQMB9xQAAAAlwSFlzAAASdAAAEnQB3mYfeAAAABl0RVh0U29mdHdhcmUATWljcm9zb2Z0IE9mZmljZX/tNXEAAAAoSURBVDjLY2hsbGQAYQjBwDAfxvg/yhhljDJG'>

This will render the PNG image directly on your webpage without needing to load an external file.


Benefits of Using Base64 Images

  • No need for additional HTTP requests.
  • Useful for embedding small images, icons, or logos directly into HTML emails or pages.
  • Keeps all your content self-contained.

⚠️ Note: Large images can increase HTML file size and slow down page loading. Use Base64 encoding mainly for small images.


You now know how to convert any PNG image into a Base64 certificate and embed it directly into your HTML pages.


Scroll to Top