I suspect the problem is with the actual Base64 data. Otherwise it looks good to me. See this fiddle where a similar scheme is working. You may try specifying the character set.

<div>
  <p>Taken from wikpedia</p>
  <img src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUA
    AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
        9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" />
</div>
Run code snippetEdit code snippet Hide Results Copy to answer Expand

You can try this Base64 decoder to see whether your Base64 data is correct or not.

Answer from VinayC on Stack Overflow
🌐
Base64.Guru
base64.guru › home › base64 converter › base64 encode
Image to Base64 | Base64 Encode | Base64 Converter | Base64
Convert image to Base64 online and use the result string as data URI, img src, css background-url, and others
🌐
CodePen
codepen.io › jamiekane › pen › YayWOa
Base64 Image Example
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAApgAAAKYB3X3/OAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAANCSURBVEiJtZZPbBtFFMZ/M7ubXdtdb1xSFyeilBapySVU8h8OoFaooFSqiihIVIpQBKci6KEg9Q6H9kovIHoCIVQJJCKE1ENFjnAgcaSGC6rEnx...
Discussions

How to display Base64 images in HTML - Stack Overflow
If you use base64 encoding, you're adding 33% overhead to the size of the image, additional CPU and memory requirements both when encoding and decoding, cluttering up the DOM with extra data that doesn't need to be there, and imposing stringent and inconsistent limits on sizes and resource types. Use blobs, object URLs... More on stackoverflow.com
🌐 stackoverflow.com
Is it a good idea to convert images into base64 string and save them in database?
You will get many people saying don't because if not implemented well it can bite ya. Don't be concerned about "optimal", tell yourself "good enough" and "don't let perfect be the enemy of good". But I have done this for several projects (enterprise, mission critical systems) and it works just fine. From the developer standpoint I love it. When I yank the "byte array" from the DB I can just pass it right to the client as-is, just adding on the mime type, super simple. Right now I have a system that stores photos of students at a university and we serve those out with an API. All done in C# and SQL Server. We have probably 50,000 photos and it is lighting fast. That being said I have also stored files in S3 and just stored the name in the DB. I will usually rename the file so S3 stores it efficiently. I like things like s3 better than a file system since you can dedicate a bucket just to this and some sysadmin won't go mucking around. I agree with you on storing the unstructured binary data along with your structured data for simplicity. I had a project once that wrote images to a filesystem. Years later older images were lost due to some file system cleanup process. Over my 25 years programming I have found you cannot guess where the issues will be. Don't optimize until you measure it. If you can build a proof of concept then hammer it, do it. Write a script that inserts and reads images and loop it for a few hours. See what happens. Also if you implement something and a few years later it starts to falter, then refactor. But you need to monitor! This is another place where people get bit, they do something like this and just let it run in a corner until it "just dies for no reason" one day. You or someone needs to care and feed for it. I am going to assume on-prem Microsoft SQL Server, your usage may vary. Use "VARBINARY(MAX)" for the field type https://docs.microsoft.com/en-us/sql/t-sql/data-types/binary-and-varbinary-transact-sql?view=sql-server-ver15 Put it in a table by itself with an id to look it up. Store filename, and filetype(mime-type) too if needed. Slap an index on the id, reference that id in other tables. Critical: Put the table in its own filegroup separate from the other tables. This will allow for faster restores since you can restore the primary filegroup and get your DB back online ASAP, then as it is up and running restore the filegroup with the images. So instead of the whole DB being down for hours, it is up in minutes with only the images being unavailable for hours. https://docs.microsoft.com/en-us/sql/relational-databases/databases/database-files-and-filegroups?view=sql-server-ver15 As with all DBs the filegroups should not be on the system (C) drive, maybe even put the images table filegroup on its own drive with nothing else. Do set a limit on the incoming filesize in your code. Someone could send in a few Blu-ray ISOs and cripple your system. In .NET code you store the image data in a byte array "byte[] " variable. That byte array is what is stored in the varbinary(max) DB field. It is easy to convert the incoming image/file to byte[], just google around for that there are many easy to do it. Design and implement a cleanup process and purge old unneeded records. No one ever seems to do this and the data grows forever until the system is retired/migrated. For small DBs it's not a problem but for this you must go back to your stakeholder and get in writing when you can delete old records then set an automated process or scheduled manual progress to do it. If they need the data long term maybe older data can be moved out of the online system and to an archive or warehouse. Microsoft has some other methods that I have not used. Check those out. https://docs.microsoft.com/en-us/sql/relational-databases/blob/binary-large-object-blob-data-sql-server?view=sql-server-ver15 -- Good luck More on reddit.com
🌐 r/dotnet
111
46
April 28, 2022
NextJS Image `blurDataURL` from HTTP URL?
It is a data url, aka base64, for a reason. So it can be embedded into the code and show up immediately. If it has to wait for a blur image first then it might just wait for the full image to begin width. What you can do is fetching the blur image on the server side, cache it, and base64 encode it and send that out to your client component. But if you aren’t doing static or ISR, you’re just making your site slower for no reason More on reddit.com
🌐 r/nextjs
2
2
March 10, 2025
Title: Using a Base64 Encoded SVG as a CSS Background-Image in Vue 3
If it's a svg why are you converting it to base64. Make it as a component and fill color directly More on reddit.com
🌐 r/vuejs
19
5
November 8, 2024
People also ask

Does base64 encoding make an image file bigger?
Yes. Base64 represents every 3 bytes of the original file as 4 text characters, so the encoded string is about 33% larger than the source image — a 30 KB icon becomes roughly 40 KB of text. That's a reasonable trade for a small icon you want to inline, but it adds up quickly for anything larger.
🌐
w3docs.com
w3docs.com › tools › image-base64
Image to Base64 Converter — Free Online Tool | W3docs
Does this tool upload my images anywhere?
No. Conversion happens entirely in your browser using the FileReader.readAsDataURL() API, and the resulting data: URI is built and shown locally — no image data is sent to a server. The page itself never calls the site's /tools/image-base64-convert endpoint; that one exists separately for scripted use.
🌐
w3docs.com
w3docs.com › tools › image-base64
Image to Base64 Converter — Free Online Tool | W3docs
Can I use the output in CSS instead of an HTML img tag?
Yes — copy the value with the Copy data URI button, not the tag text, and drop it into any url(), for example background-image: url("data:image/png;base64,..."). A data URI is just text, so it works in CSS, inline styles, or a JSON config exactly as well as it works in HTML.
🌐
w3docs.com
w3docs.com › tools › image-base64
Image to Base64 Converter — Free Online Tool | W3docs
🌐
Elmah.io
elmah.io › tools › base64-image-encoder
Base64 Image Encoder - Convert any image file or URL online
Once converted to Base64, encoded image data will look similar to this (shortened for simplicity): iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgwnLpRPAAA... The string can be used instead of an URL in the src attribute of the img element in HTML:
🌐
GeeksforGeeks
geeksforgeeks.org › html › how-to-display-base64-images-in-html
How to Display Base64 Images in HTML (With Example) - GeeksforGeeks
3 weeks ago - Lazy loading: Use loading="lazy" to delay the loading of images until the user scrolls near them, which can be helpful for Base64 images that might impact initial page load time. ... For Base64, we will consider the Data URL of the image, which is placed in the src attribute.
🌐
GitHub
gist.github.com › LeeHanYeong › c104ba1b0f637b9c8e54d68919862405
Sample Base64 Image · GitHub
Learn more about clone URLs · Clone this repository at &lt;script src=&quot;https://gist.github.com/LeeHanYeong/c104ba1b0f637b9c8e54d68919862405.js&quot;&gt;&lt;/script&gt; Save LeeHanYeong/c104ba1b0f637b9c8e54d68919862405 to your computer and use it in GitHub Desktop. Download ZIP · Sample Base64 Image ·
🌐
W3docs
w3docs.com › tools › image-base64
Image to Base64 Converter — Free Online Tool | W3docs
Yes — copy the value with the Copy data URI button, not the <img> tag text, and drop it into any url(), for example background-image: url("data:image/png;base64,...").
Find elsewhere
🌐
Base64 Image Encoder
base64-image.de
Convert Images to Base64 Online — Free Encoder & Optimizer | base64-image.de
Email clients often block external images by default. Base64 encoded images are embedded directly in your email HTML, ensuring your images display immediately without requiring user permission or external server access.
🌐
JSFiddle
jsfiddle.net › casiano › Xadvz
base64 testing image - JSFiddle - React, Tailwind, and code Playground
JSFiddle - Test your React, Tailwind, JavaScript, CSS, HTML online with JSFiddle.
🌐
Jaredwinick
jaredwinick.github.io › base64-image-viewer
Base64 Image Viewer
We cannot provide a description for this page right now
🌐
Base64 Image Encoder
base64-image.de › home › tutorial
Tutorial - Base64 Image Encoder
/* Store base64 in a CSS variable for reuse */ :root { --icon-checkmark: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0i...'); } .success-badge::after { content: ''; width: 14px; height: 14px; background: var(--icon-checkmark) no-repeat center; background-size: contain; }
🌐
Base64.Guru
base64.guru › home › base64 converter › base64 encode › image
JPG to Base64 | Image | Base64 Encode | Base64 Converter | Base64
.base64 { background-image: url("data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAZABkAAD/2wCEABQQEBkSGScXFycyJh8mMi4mJiYmLj41NTU1NT5EQUFBQUFBREREREREREREREREREREREREREREREREREREREQBFRkZIBwgJhgYJjYmICY2RDYrKzZERERCNUJERERERERERERERERERERERERERERERERERERERERERERERERERP/AABEIAAEAAQMBIgACEQEDEQH/xABMAAEBAAAAAAAAAAAAAAAAAAAABQEBAQAAAAAAAAAAAAAAAAAABQYQAQAAAAAAAAAAAAAAAAAAAAARAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhEDEQA/AJQA9Yv/2Q==") }• HTML Favicon:
🌐
Base64image
base64image.org
Base64 Image Encoder & Decoder — Convert Image to Base64 Online
Free online Base64 image tool. Convert an image to a Base64 data URI, or decode Base64 back to an image — right in your browser. Copy as HTML img tag or CSS background, with code examples.
🌐
GitHub
gist.github.com › ondrek › 7413434
Smallest Base64 image · GitHub
Note that with Base64 you can usually get away with trimming any = from the end of the string as they are just padding. ... iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII · that's exactly what I was looking for. Thanks a lot. ... data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII
🌐
CSS-Tricks
css-tricks.com › data-uris
Data URIs | CSS-Tricks
October 30, 2024 - It’s hard to maintain site with embedded data URIs for everything. It’s easier to just update an image and replace it. If you are using PHP (or PHP as CSS), you could create data URIs on the fly like this: <?php echo base64_encode(file_get_contents("../images/folder16.gif")) ?>
🌐
AngryTools
angrytools.com › img-base64
Image Base64
Base64 is a binary-to-text encoding scheme that is commonly used to represent binary data, such as images. To convert image into base64 image format that can be use in CSS background property or IMG source attribute.CSS Code · div { background-image:url('data:image/png;base64ImageCode'); }IMG Code
🌐
Sentry
sentry.io › sentry answers › html › how do i display a base64 image in html?
How do I display a Base64 image in HTML? | Sentry
January 15, 2024 - For instance, don’t use Base64 to display an image on the page after a user has uploaded or selected an image from their computer. If your page has access to JavaScript and the internet, you should rather use createObjectURL. Here’s an example that creates a blob from a file, creates a temporary URL pointing to the blob (automatically handled by the browser), and adds it as an image to the document.
🌐
DebugBear
debugbear.com › blog › base64-data-urls-html-css
Page Speed: Avoid Large Base64 data URLs in HTML and CSS | DebugBear
April 15, 2026 - Base64 encoding increases file size by approximately 33% compared to the original data. Here's an example of a simple data URL, in this case a single-pixel SVG image.
🌐
Formspree
formspree.io › blog › image-to-base64
How to Convert an Image URL to Base64 | Formspree
August 28, 2024 - Have you ever run into a situation where you needed to include an image directly into an HTML webpage instead of hosting it on a fileserver and linking to it using a URL? For example, let’s say you’re designing a webpage with lots of small decorative images, like background icons or patterns. These images aren’t meant to be SEO-friendly—they’re just design elements that you want to keep embedded within the HTML to reduce the number of HTTP requests. Converting these to base64 strings can help in this situation.
🌐
Base64.Guru
base64.guru › home › tools
Data URL to image | Tools | Base64
... If someone were to create a page like this, but it was reached via a URL like https://base64.guru/tools/data-url-to-image/(Image → Base64 → Percent-encoding) eg; https://base64.guru/tools/data-url-to-image/data:image/gif;base64,R0lGODlhZABkAPcAAAAAAAAAMwAAZgAAmQAAzAAA/wArAAArMwArZg...