Convert Image URL to Base64: Free Online Tool (No Code Needed)
Quick answer: To convert image url to base64, paste the link into a free online converter like ToolFlexy’s Image to Base64 tool, which fetches the image in your browser and instantly returns a Base64 string, Data URI, or ready-to-use HTML/CSS snippet — no download, sign-up, or code required.
Learning how to convert image url to base64 is useful any time you need to embed a picture directly in HTML, paste it into a CSS file, or drop it into a JSON payload. The fastest way is a free online converter that fetches the image and encodes it for you. No account, no software, and no code required.
ToolFlexy’s Image to Base64 tool does exactly this: paste a link, and it fetches and encodes the image right in your browser. Below is exactly how to convert image to Base64 from a URL, why some links won’t convert (a problem almost nobody explains properly), and a quick code snippet if you’d rather handle it yourself.
What Does It Mean to Convert Image URL to Base64?
Base64 is a way of representing binary data — like an image file — as plain text. When you convert image url to base64, a tool downloads the image at that link and re-encodes its raw bytes into a long string made of letters, numbers, and a few symbols.
That string can then be pasted anywhere plain text is accepted: directly into an HTML <img> tag, a CSS background-image rule, a JSON payload, or an email template, without linking to an external file at all. The image effectively becomes part of the document itself, rather than a separate resource the browser has to fetch.
This is different from simply linking to an image URL. A normal <img src="https://example.com/photo.jpg"> tag still depends on that external file existing and being reachable every time the page loads. A Base64-encoded image doesn’t — once you’ve converted the image URL to Base64 and pasted the resulting string into your code, the image data travels with the document itself.
How to Convert Image URL to Base64 Online (Free)
Here’s the fastest way to convert image url to base64 without writing any code:
- Open the Image to Base64 tool. It runs entirely in your browser — nothing you convert is uploaded to a server.
- Find the “Import from the Web” box and paste your image’s direct URL into the “Have an image link?” field.
- Click “Fetch & Convert.” The tool downloads the image and encodes it instantly, right there in the page.
- Pick your output format. Choose Raw Base64, Data URI, HTML, CSS, JSON, XML, a JS variable, or a Favicon tag, depending on where the code is headed.
- Copy the result with one click, or download it as a .txt file to use later.
No sign-up, no vague limits (there’s a clearly stated 15MB file size cap), and no watermark on the output. If you’d rather start from a file already saved on your device instead of a link, the same tool also accepts drag-and-drop uploads and clipboard paste — the URL method is just the fastest way to convert image url to base64 when you already have a link and don’t want to download it first.

Choosing the Right Output Format
Once you convert image url to base64, you’ll need to pick a format that matches where the code is going. Here’s what each option is actually for:
- Raw Base64 — just the encoded string, no prefix. Useful when a system expects the data on its own, such as an API field that already knows the content is an image.
- Data URI — the Base64 string with a
data:image/png;base64,prefix attached. This is what you need for thesrcattribute of an<img>tag or a CSSurl()value, since the prefix tells the browser how to interpret the text that follows. - HTML — a ready-made
<img>tag with the Data URI already inserted, so you can paste it straight into a page. - CSS — a
background-imagerule, pre-formatted for a stylesheet. - JSON — the encoded image wrapped as a field in a JSON object, for sending through an API.
- XML, JS Variable, or Favicon tag — the same underlying Base64 data, reformatted for whichever one of those three contexts you’re working in.
Getting the format right the first time avoids a common mistake: pasting raw Base64 (with no prefix) directly into an <img src> attribute and getting a broken image, when what that attribute actually needed was the Data URI version with the data:image/...;base64, prefix included.
Why Some Image URLs Won’t Convert (The CORS Issue Nobody Explains)
Occasionally, when you try to convert image url to base64, pasting the link and clicking convert returns an error instead of a result. This isn’t a bug in the tool — it’s a browser security restriction called CORS (Cross-Origin Resource Sharing), and most guides on this exact topic skip it entirely.
Here’s what’s actually happening. A real browser-based converter fetches the image using your own browser, not a hidden server somewhere. That request has to follow the same cross-origin rules (CORS) any webpage does. If the image’s own server doesn’t explicitly allow outside sites to fetch it, your browser blocks the request before the tool ever sees the image data — and there’s no workaround from the browser side, by design.
It’s the same protection that stops a random website from silently reading data off another site you’re logged into. Without it, any page you visit could quietly pull private content from your bank’s site or your email in the background. CORS exists specifically to prevent that, and it applies just as strictly to a harmless image fetch as it does to anything else.
This is also a useful way to evaluate any tool that claims to always be able to base64 encode an image url, no matter the source. A tool that routes your image through its own server to dodge CORS can technically get around the restriction, but it means the image is no longer staying private in your browser. It passes through someone else’s infrastructure first, which runs against the entire point of a “nothing uploaded” tool.
If you hit this error, two options reliably work:
- Download the image first, then upload the file directly instead of pasting the URL. This works every time, since there’s no cross-origin request involved at all.
- Use an image hosted somewhere that explicitly allows cross-origin access, such as a CDN or a storage bucket configured for public access.
How to Base64 Encode an Image URL in JavaScript
If you’re building this into your own app instead of using a tool, here’s the core pattern for how to base64 encode an image url using the Fetch API:
async function imageUrlToBase64(url) {
const response = await fetch(url);
const blob = await response.blob();
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onloadend = () => resolve(reader.result); // includes the data: prefix
reader.onerror = reject;
reader.readAsDataURL(blob);
});
}
The same CORS rule from above applies here too. This snippet throws an error for any image URL whose server doesn’t send the right CORS headers, regardless of how clean the code is. That isn’t something you can fix in JavaScript; it has to be allowed on the image’s server side, which is outside your control as the person requesting the image.
If you’re working server-side instead (Node.js, Python, or similar), CORS doesn’t apply at all, since the restriction is enforced by browsers, not servers. A backend script can fetch nearly any public image URL and encode it as Base64 directly, which is why server-side code is often the more reliable choice when you need to encode image urls at scale rather than one at a time.
Where to Use a Base64-Encoded Image
Once you convert image url to base64, the resulting string is most useful in a handful of specific situations, rather than as a general replacement for normal image links:
- Small icons and logos in CSS or HTML — embedding avoids a separate HTTP request for a tiny file, which can genuinely speed up a page with many small graphics.
- Email templates — some email clients handle inline images more reliably than externally linked ones, which often get blocked by default.
- JSON APIs or config files — where an image needs to travel as part of a text payload instead of as a separate attachment.
- Quick prototypes — pasting a Base64 string into an
<img>tag to test something without hosting a file anywhere first.
One tradeoff is worth knowing before you convert an image to Base64 for production use: the resulting text is roughly 33% larger than the original image file. For a small icon, that’s negligible. For anything bigger, that overhead adds up fast, which is why it’s worth compressing an image or resizing it before encoding, rather than converting a large photo as-is.
If your source image is in a format like HEIC or TIFF, converting it to something web-friendly first with a tool like HEIC to JPG or the Image Resizer keeps the final Base64 string smaller too, since those formats tend to produce bulkier output than a well-compressed JPG or WEBP.
Common Mistakes When You Convert Image URL to Base64
Most people who try to base64 encode image url data run into one of the same handful of issues. A few small mistakes account for most of the confusion:
- Forgetting the
data:prefix when pasting a Data URI into an<img src>attribute — without it, the browser has no way to know the string is image data rather than plain text. - Converting a large, uncompressed photo instead of a small icon, which produces a Base64 string that’s awkward to work with and slows down whatever file it’s pasted into.
- Assuming a failed conversion means the tool is broken, when it’s usually the CORS restriction described above, tied to the source server rather than the converter.
- Using Base64 for every image on a page instead of just small, repeated assets — for large or unique images, a normal linked file (with caching) is almost always faster to load.
Conclusion
When you need to convert image url to base64, it comes down to one real choice: use a free browser-based tool for a quick, one-off conversion, or write a few lines of code if you’re automating it inside an app. Either way, the CORS restriction is the one factor that actually determines whether a given URL will convert, not the tool you pick.
Try the Image to Base64 converter now. Paste a link to convert image url to base64 instantly, or upload a file, and get your Base64 string, Data URI, or HTML tag in seconds.