Image to Base64 Converter
Encode an image as a data URL or raw Base64 for HTML, CSS, JSON, and scripts.
Choose an image to encode
PNG · JPG · GIF · WEBP · SVG — up to 25 MB
Encoding runs in this browser
Browser-based conversion
- →Your image is read with the browser's FileReader API
- →No account required for browser-based encoding
- →Copy a data URL or raw Base64 string
Base64 output is about 33% larger than the original file, so this tool works best for images under a few MB. Large images are still supported up to 25 MB.
How to Convert an Image to Base64
- 1
Choose an image
Click the upload area, drag a file in, or paste from your clipboard. PNG, JPG, GIF, WEBP, SVG, and other browser-readable formats work.
- 2
Watch it encode
Your browser reads the file and produces the data URL instantly.
- 3
Pick your output
Use the Data URL tab for HTML/CSS embedding or the Raw Base64 tab for APIs, JSON, and databases.
- 4
Copy or download
Copy the full string to your clipboard or download it as a .txt file for later.
Why Convert Images to Base64
Base64 turns image bytes into text that can be embedded directly in HTML, CSS, JSON, or API payloads without a separate image request.
Instant browser encoding
The FileReader API produces the Base64 string directly in this page.
Data URL and raw Base64
Switch between a complete data URL for HTML and CSS, or the raw Base64 string for JSON payloads, APIs, and storage.
One-click copy
Copy the full output — not a truncated preview — straight to your clipboard, even when the string is hundreds of thousands of characters long.
Download as a text file
Save the encoded output as a .txt file so you can move large Base64 strings between tools without losing them.
Paste support
Copy a screenshot or image in another app and paste it directly with Ctrl/Cmd+V. Encoding starts immediately.
No account required
Encoding runs in this page, with no account or daily conversion limit.
Supported Formats and Limits
Supported formats
Any format your browser can render and read, including PNG, JPG, GIF, WEBP, SVG, AVIF, and BMP. The data URL preserves the original MIME type.
Size limit
Files up to 25 MB are accepted. Base64 output is about 33% larger than the source, and encoding happens in memory, so oversized files are rejected instead of freezing your browser.
Where to Use Base64 Image Strings
Once the converter above produces a string, the next question is where it belongs. Copy a template and replace the ... with the full payload — it stands for the rest of the Base64 string, not literal code.
Use the Data URL output for HTML, CSS, and favicons. Use the Raw Base64 output for JSON and API payloads.
HTML <img> tag
Inline an icon or badge with no separate image request. Keep the alt text and dimensions so the image stays accessible and does not shift the layout.
<img src="data:image/png;base64,iVBORw0KGgo..." alt="Icon" width="24" height="24" />CSS background image
Embed a decorative image directly in a stylesheet. For SVG, a URL-encoded data URI is usually smaller than a Base64 one, but both work.
.icon {
background-image: url("data:image/svg+xml;base64,PHN2Zy...");
background-size: 24px 24px;
}HTML favicon (single-file page)
Useful when the whole page must be one self-contained file. A favicon data URL adds weight to every page load and cannot be cached on its own.
<link rel="icon" href="data:image/png;base64,iVBORw0KGgo..." />JSON / REST API payload
Use the Raw Base64 tab for API fields. Leave out the data: prefix — the receiving service normally supplies the MIME type itself.
{
"filename": "avatar.png",
"content_base64": "iVBORw0KGgo..."
}Base64 Data URL vs. Hosted CDN Image URL
Base64 keeps a small asset inside the document. A hosted URL is lighter and easier to reuse when the image is a photo, a screenshot, or anything that appears on more than one page.
| Dimension | Base64 Data URL | Hosted CDN URL (Image to URL) |
|---|---|---|
| Best file size | Tiny icons, logos & UI badges (under 10 KB) | Photos, screenshots & blog visuals — 3 MB free, up to 256 MB on Enterprise |
| Payload overhead | About 33% larger than the original binary | 0% encoding overhead — serves the original file bytes |
| Browser caching | Cached only as part of the HTML/CSS that contains it | Cached at Cloudflare edge nodes and reusable across pages |
| Markdown / GitHub | Stripped or blocked by GitHub and many Markdown parsers | Works in GitHub, Notion, Obsidian, and most Markdown renderers () |
Hosting a photo, screenshot, or an image you will reuse? Upload it once and share a direct CDN URL instead.
Upload to Image to URLHow Your Image Is Processed
Image to Base64 reads the selected file with the FileReader API and encodes it directly in the page. The resulting data URL or raw Base64 string can be copied or downloaded.
If you need a hosted public URL instead of a data string, use the Image to URL converter.
Frequently Asked Questions
Is the Image to Base64 converter free?
Yes. Encoding uses the browser's FileReader API, with no account requirement or daily conversion limit. You can copy or download the result.
How is my image read?
The image is read with the browser's FileReader API and converted to a Base64 string in this page. When you leave or refresh the page, the encoded result disappears.
What is the difference between a data URL and raw Base64?
A data URL includes the MIME prefix — for example data:image/png;base64,iVBORw0KGgo... — and can be used directly in an img src or CSS url(). Raw Base64 is just the encoded text after the comma, which you can store or transmit and prefix yourself when needed.
Which image formats are supported?
Any image format your browser can read: PNG, JPG, GIF, WEBP, SVG, AVIF, BMP, and more. The original MIME type is preserved in the data URL.
What is the maximum file size?
Files up to 25 MB are accepted. Base64 output is roughly 33% larger than the original, and very large files can consume significant browser memory, so the tool rejects anything over 25 MB with a clear message.
Why is the Base64 output bigger than my image?
Base64 encodes binary data using 64 characters, so it needs about 4/3 as many characters as the original file has bytes. That size difference is normal and applies to every Base64 encoder.
How do I convert Base64 back into an image?
Use Photo2URL's Base64 to Image tool, which decodes Base64 and data URLs back into a previewable, downloadable image file with native browser APIs.