Image to Base64
Convert image to Base64 online and use the result string as data URI, img src, CSS background-url, and others. Sometimes you have to send or output an image within a text document (for example, HTML, CSS, JSON, XML), but you cannot do this because binary characters will damage the syntax of the text document. To prevent this, for example, you can encode image to Base64 and embed it using the data URI. Please note that the image 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 Image.
Additional image encoders
The Image to Base64 converter generates ready-made examples, depending on the selected output format. It automatically detects the content type of the uploaded image, so that you simply copy the complete result. If you need to encode specific image formats, please follow the links below.
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 image formatted in each of the available formats (as an example image I use a one-pixel red dot GIF file):
• Plain text:R0lGODdhAQABAPAAAP8AAAAAACwAAAAAAQABAAACAkQBADs=
• Data URI:data:image/gif;base64,R0lGODdhAQABAPAAAP8AAAAAACwAAAAAAQABAAACAkQBADs=
• CSS Background Image:.base64 {
background-image: url("data:image/gif;base64,R0lGODdhAQABAPAAAP8AAAAAACwAAAAAAQABAAACAkQBADs=")
}
• HTML Favicon:<link rel="shortcut icon" href="data:image/gif;base64,R0lGODdhAQABAPAAAP8AAAAAACwAAAAAAQABAAACAkQBADs=" />
• HTML Hyperlink:<a href="data:image/gif;base64,R0lGODdhAQABAPAAAP8AAAAAACwAAAAAAQABAAACAkQBADs="></a>
• HTML Image:<img alt="" src="data:image/gif;base64,R0lGODdhAQABAPAAAP8AAAAAACwAAAAAAQABAAACAkQBADs=" />
• HTML Iframe:<iframe src="data:image/gif;base64,R0lGODdhAQABAPAAAP8AAAAAACwAAAAAAQABAAACAkQBADs=">
The “iframe” tag is not supported by your browser.
</iframe>
• JavaScript Image:var img = new Image();
img.src = "data:image/gif;base64,R0lGODdhAQABAPAAAP8AAAAAACwAAAAAAQABAAACAkQBADs=";
document.body.appendChild(img);
• JavaScript Popup:window.onclick = function () {
this.open("data:image/gif;base64,R0lGODdhAQABAPAAAP8AAAAAACwAAAAAAQABAAACAkQBADs=");
};
• JSON:{
"image": {
"mime": "image/gif",
"data": "R0lGODdhAQABAPAAAP8AAAAAACwAAAAAAQABAAACAkQBADs="
}
}
• XML:<?xml version="1.0" encoding="UTF-8"?>
<root>
<image mime="image/gif">R0lGODdhAQABAPAAAP8AAAAAACwAAAAAAQABAAACAkQBADs=</image>
</root>
If I missed an important output format for Base64-encoded images, please let me know — I would love to implement it.
Comments (47)
I hope you enjoy this discussion. In any case, I ask you to join it.
I would create a small php script with a foreach loop over the .csv file and convert the images on the fly to base64 and save it in a text file, for example.
If you need help with it, feel free to ask. just google for my personal website davidduckwitz dot de...
Perhaps you can give me some direction!
I want to extract from javascript (using btoa method?) a base64 code contained in a xml se:InlineContent element. It looks like:
<se:InlineContent encoding="base64">
your plain text output
</se:InlineContent>
I wonder:
- did I locate correctly your plain text output?
- is the plain text the value of the encoding attribute?
- how can I take the plain text output and bring it to a varaible in javascript? I have done this but it doesnt work:
const stringFromBase64 = inlineContent.$['encoding']
Thx
<Form action="" method="post">
<input type="text" name="username" placeholder="username">
<input type="text" name="email" placeholder="email">
</form>
in this form I also need to send an image of base64 format...the thing is I don't want to upload image from my local system, but I have to capture image from my webcam at realtime and need to send...someone please help me.
navigator.mediaDevices
.Browser version is Edge latest and OS is win 10 Pro fully updated.
Cheers,
Pete.
By the way, if you need it as "Plain text" or "Data URI", please take a look at the Base64 Encoder. It allows you to specify the Base64 Standard, so you can choose the MIME standard and the output will be splitted into fixed 76 line-length.
Pete.
Best wishes,
Victor
[UPDATED: ]
So i need nice rows (justified text). But how do i get them?
[UPDATED: ]
oh, my bad. I had to use the correct imgage-quality for the picture.
CURLOPT_SSL_VERIFYHOST
andCURLOPT_SSL_VERIFYPEER
to0
(zero).<img alt="" src="data:image/heic;base64,mybase64img" />
any suggestions?and it says • Wrong file type (received “application” while waiting for “image”). Anyway, do not worry, you still got a properly result and this warning is not related to the data encoding.
anyways decoding the outputput I was able to view the image! What happened there?
Preferably Java but ok if other.
how exactly does it work??
No protection
169.30M
15522
com.tencent.ig
/data/user/0/com.tencent.ig
/data/app/com.tencent.ig-Jg89O1T2LjgUxm3dXn0BQg==/base.apk
12759
APK path
UID
Installed version
Protection
![altname](data:image/png;base64,$base64$)
Instead of buying you a cup of coffee — I'll be happy to buy you a WHOLE POT OF COFFEE if you can send me the actual code you've written. It does exactly what I need to do with a little project I'm working on for a not-for-profit org. Please let me know if you are interested in helping out.
Thanks,
Sas
on nails,Red press on nailsChuan Chuan Fashion has redefined nail care in Australia by
offering gel press-on nails that combine style, quality, and convenience.
With their diverse range of press-on nails and polygel
nail kits, achieving salon-worthy nails at home has never been easier.
Say goodbye to long salon appointments and hello to the future of nail beauty with Chuan Chuan Fashion.
I'm using base64 code to insert image in a html page. BUT, what I'm facing is strange. There are characters that cause an issue when saving the html page. Issue : "This email message cannot contain the following words/terms..."
Is there a way to change the forbidden characters by others ? Or is it possible to generate base64 code without forbidden terms ?
Thanks in advance for your replies.
Kind regards,
Chris
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AL ZAIN THE FASHION STUDIO</title>
<style>
body {
font-family: 'Arial, sans-serif';
background-color: #102810;
color: #f1e5ac;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
}
header {
padding: 20px;
text-align: center;
}
header img {
max-width: 100%;
height: auto;
}
main {
padding: 20px;
max-width: 800px;
}
footer {
margin-top: 20px;
padding: 20px;
font-size: 14px;
}
.welcome-message {
font-size: 1.5em;
margin: 20px 0;
}
</style>
</head>
<body>
:citation[oaicite:0]{index=0}
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AL ZAIN THE FASHION STUDIO</title>
<style>
body {
font-family: 'Arial, sans-serif';
background-color: #102810;
color: #f1e5ac;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
}
header {
padding: 20px;
text-align: center;
}
header img {
max-width: 100%;
height: auto;
}
main {
padding: 20px;
max-width: 800px;
}
footer {
margin-top: 20px;
padding: 20px;
font-size: 14px;
}
.welcome-message {
font-size: 1.5em;
margin: 20px 0;
}
</style>
</head>
<body>
:citation[oaicite:0]{index=0}