Converting image...
โ Conversion Complete
src attribute in an HTML
<img> tag or as a CSS url() value.
๐ป How to Use Base64 Images in Code
Once you have your Base64 string, here are ready-to-use code
snippets for every scenario. Replace BASE64_STRING
with your actual output:
<img src="data:image/png;base64,BASE64_STRING" alt="My Image" width="200" height="auto" />
.my-element { background-image: url("data:image/png;base64,BASE64_STRING"); background-size: cover; background-repeat: no-repeat; }
const img = new Image(); img.src = "data:image/png;base64,BASE64_STRING"; img.alt = "My Image"; document.body.appendChild(img);
{
"filename": "image.png",
"mimeType": "image/png",
"data": "BASE64_STRING"
}
const MyImage = () => ( <img src={`data:image/png;base64,BASE64_STRING`} alt="My Image" style={{ width: '100%' }} /> );
<!-- Use in HTML email templates --> <img src="data:image/png;base64,BASE64_STRING" alt="Logo" width="150" style="display:block; max-width:150px;" />
๐ How to Use the Image to Base64 Converter
Drop or Select Your Image
Drag and drop any image file into the drop zone, or click it to open the file browser. You can select multiple images at once. Supports PNG, JPG, GIF, WebP, SVG, BMP, and more.
Conversion Happens Instantly
Your image is converted to Base64 immediately in your browser. No uploading, no waiting. The preview and all file metadata appear right away.
Choose Your Output Format
Select from 5 output formats using the tabs โ Data URI (use as image src), Base64 (raw string), HTML img tag, CSS background, or Markdown.
Copy or Download
Click Copy Output to copy to clipboard or Download .txt to save the Base64 string as a text file. Use Test Preview to verify the Base64 renders correctly.
โ Frequently Asked Questions
โข Reduce HTTP requests โ Embed small icons directly in HTML/CSS
โข HTML emails โ Some email clients block external images; inline Base64 ensures the image always shows
โข API responses โ Pass image data in JSON without a separate file endpoint
โข Offline apps โ Bundle images directly in the app without external files
โข Single-file HTML โ Create fully self-contained HTML documents
FileReader API. Your image never leaves your device. It is never uploaded, never stored, and never seen by anyone. You can even disconnect from the internet and the tool will still work.
iVBORw0KGgo...).A Data URI includes a header that tells the browser what type of data it is, followed by the Base64 string:
data:image/png;base64,iVBORw0KGgo...Use the full Data URI when setting it as an
src attribute or CSS url(). Use the raw Base64 string when storing data in databases or API payloads where the type is handled separately.