Image to Base64
Encode an image as a Base64 data URL.
About this tool
Choose an image and press Process. You get its Base64 data URL, which you can paste into an img tag, a CSS background or a JSON field.
How to use
How it works
The file is read as bytes and encoded as a data URL, starting with data: followed by the file's type and;base64,. Base64 turns every 3 bytes into 4 characters, so the text is about one third larger than the file. The original file type is kept, so a PNG stays PNG.
Base64 length ≈ file bytes × 4 ÷ 3
Worked example
A small icon
- Input
- A 3 KB PNG icon
- Output
- A data URL of roughly 4 KB
- Walkthrough
- 3 KB × 4 ÷ 3 = 4 KB of Base64 characters, plus the short data: prefix.
Limitations
- Output is about 33% larger than the file.
- Large images create very long strings that are unwieldy in HTML or CSS.
- The result includes the data: prefix; remove it if an API wants bare Base64.
Questions
How do I convert an image to Base64?
Does the result include data:image/png;base64,?
Is the image uploaded?
Features
- Full data URL
- Any image type
- Private, in-browser
Related resources
Guides and videos from around the web—opens on YouTube or the publisher’s site.
How Image Compression Works
Leo Isikdogan
Compression intuition for resize and optimize image tools.
Watch on YouTubeResponsive images - PWA Training
Chrome for Developers
How image weight affects real-device performance.
Watch on YouTube
- Image file type and format guide
MDN
JPEG, PNG, WebP, AVIF tradeoffs for convert and compress tools.
- Efficiently encode images
Chrome Developers
Lighthouse image budgets that motivate compress tools.