About the Image to Base64
Image to Base64 converts a picture into a data URI: a text string that starts with data:image/...;base64, and contains the whole file encoded as Base64. You can paste it directly into an img src, a CSS background or a JSON field, with no separate image file needed.
How it works
The tool reads your file with the browser's FileReader.readAsDataURL, which produces data:, the file's MIME type (such as image/png), ;base64, and then the file's bytes encoded in Base64. The bytes are not changed or re-compressed; it is the exact original file written as text.
Base64 represents every 3 bytes as 4 characters from a 64-character alphabet (A-Z, a-z, 0-9, + and /), padding the end with =. That is why the encoded string is about 33% larger than the file. The output panel shows only the first 500 characters to keep the page fast, but the Copy button copies the entire string.
How to use
- 1
Click the file button and choose an image.
- 2
Check the preview to make sure it is the right image.
- 3
Click Copy to copy the full data URI.
- 4
Paste it into an img src attribute, a CSS url(), or wherever you need it.
Worked examples
Icon in CSS
A 1.2 KB PNG icon used as a button background.
Every PNG's Base64 begins with iVBORw0KGgo, the encoded PNG signature. 1,200 bytes become 1,600 Base64 characters plus the 22-character prefix. Use it as background-image: url("data:image/png;base64,...").
Logo in an HTML email
Embedding a small JPEG logo.
JPEG data URIs start with /9j/, the encoded JPEG marker. Note that some email clients, including Gmail, block data URI images, so test before sending.
Frequently asked questions
When is embedding an image as Base64 useful?+
For small icons and images where avoiding a separate file or request matters more than the roughly 33% larger size, such as CSS icons or self-contained HTML files.
Does Base64 encoding reduce image quality?+
No. It is a lossless text representation of the exact same file bytes, so the image is identical when decoded.
How do I use the result in HTML?+
Paste it as the src: <img src="data:image/png;base64,..." alt="...">. In CSS, wrap it in url("...").
Why is only part of the string shown?+
Long strings can freeze the page, so the panel shows the first 500 characters followed by an ellipsis. The Copy button always copies the complete data URI.
Why is the Base64 version bigger than my file?+
Base64 uses 4 text characters for every 3 bytes, so the output is about one third larger than the original.