Image to Base64
Convert any image into a Base64 data URI, CSS background or ready-made HTML tag.
Turn an image into Base64
Data URI · CSS · HTMLNo image yet. Add one and you get a ready-to-paste data URI, CSS rule and HTML tag.
Preview
—
Raw data URI
CSS background-image
HTML img tag
CSS background-color fallback
How to convert an image to Base64
Upload the image
Drop a picture into the upload zone or click it to browse. The file is read with the browser File API and never leaves your device.
Pick the output format
Use the tabs to switch between the raw data URI, a CSS background-image rule, a ready-made HTML img tag or a background-colour fallback.
Add alt text
Type a short description so the generated HTML tag stays accessible for screen readers.
Copy or download
Hit the Copy button on any tab, or download all four variants as a single .txt file for your code editor.
Image to Base64 converter — frequently asked questions
A data URI embeds a file directly inside a URL using the data:[media-type];base64,[payload] format. Because the whole payload travels inside the link, you can ship an image inside an HTML document, a CSS file or a JSON payload without any extra request.
Base64 encodes every three bytes into four characters, so the encoded payload is about 33% bigger than the raw file. The tool shows the exact character count, the decoded byte size and the overhead so you can decide whether embedding is worth it.
A CSS background is the better choice for decorative images, sprite-like icons and placeholder art, because you can control the repeat, position and size without adding markup. Use an HTML img tag for meaningful content, because it supports the alt attribute and modern screen readers.
Most browsers and email clients start to struggle with data URIs above roughly 2 MB, and some servers cap request or header sizes. Keep embedded images small, or host the file and reference it with a normal URL when the picture is large.
Related Image Tools
Image Compressor
Compress JPG, PNG and WEBP images with a custom quality slider and instant size comparison.
Open toolImage Resizer & Scaler
Resize images by pixel dimensions or percentage, with ready-made social media ratios.
Open toolImage Format Converter
Convert photos between PNG, JPG, WEBP and BMP formats without losing quality.
Open toolPassport Photo Maker
Create compliant 2x2 in and 35x45 mm passport photos with custom backgrounds and print grids.
Open toolImage Cropper & Rotate
Crop, rotate, flip and adjust the brightness of any picture.
Open toolImage to Base64
Convert any image into a Base64 data URI, CSS background or ready-made HTML tag.
Open tool