What the Image to Base64 does
Image to Base64 asks for one image file and, as soon as you choose it, reads it with the browser's FileReader.readAsDataURL method. The result is a data URL: the word data, a colon, the file's media type, the marker ;base64, a comma and then the file's bytes in Base64. It appears in a read-only box with a character count, and two buttons let you copy it to the clipboard or download it as a text file named after the original, for example logo.png-base64.txt.
Nothing about the image is changed. The tool never draws the file onto a canvas, so there is no re-encoding, no quality loss, no colour-profile conversion and no metadata removal. A PNG keeps its transparency, an animated GIF keeps every frame, an SVG stays a vector document, and a JPEG keeps its EXIF block. The Base64 is simply the file, byte for byte, in a text-safe form.
The media type in the prefix is whatever your browser reports for the file, which it usually derives from the extension: image/png, image/jpeg, image/webp, image/gif or image/svg+xml. The file picker is filtered to image types, but the content is never inspected, so a file with an unusual extension can produce a prefix without an image type and a format the browser cannot display still encodes without complaint.
Base64 writes three bytes as four characters, so the text is about a third larger than the file plus a short prefix. A 30,000-byte PNG becomes 40,000 characters of Base64 after a 22-character prefix. That is fine for icons and small logos embedded in a stylesheet, an email signature or a JSON fixture, and a poor choice for photographs, which belong in a separate cached file.
How to use it
Choose an image
The picker shows image files by default: PNG, JPG, WebP, GIF, SVG and anything else your system labels as an image. One file at a time.
Wait for the data URL
There is no convert button; the data URL appears under the picker as soon as the file is read, with its length in characters. A file that cannot be read shows the message This image could not be read.
Copy or download it
Copy puts the whole string on the clipboard for an img src or a CSS url(). Download TXT saves it as a plain-text file named after the image.
What a data URL contains
The scheme is defined in RFC 2397 and documented on MDN. After data: comes an optional media type, then ;base64 to say the payload is Base64 rather than percent-encoded text, then a comma and the payload. If the media type is left out, browsers assume text/plain in US-ASCII, which is why the prefix matters for an image: without image/png or image/jpeg a browser will not render the bytes as a picture.
The first characters after the comma identify the format, because every image type starts with a fixed signature. A PNG begins iVBORw0KGgo, a JPEG begins /9j/, a GIF begins R0lGOD, a WebP begins UklGR (the RIFF container) and an SVG begins PHN2Z or PD94bWwg depending on whether the file opens with an svg tag or an XML declaration. If the prefix says one type and the payload starts with another signature, the file extension was wrong.
- data:image/png;base64,iVBORw0KGgo... is a PNG
- data:image/jpeg;base64,/9j/... is a JPEG
- data:image/gif;base64,R0lGOD... is a GIF
- data:image/webp;base64,UklGR... is a WebP
- data:image/svg+xml;base64,PHN2Z... is an SVG
Where to paste it and where it will not work
In HTML, the string is the value of an img element's src attribute. In CSS, it goes inside url() as a background-image or a list-style-image, with quotes around it to be safe. In JSON or a test fixture it is an ordinary string. The same data URL also opens in a browser tab if pasted into the address bar, which is a quick way to confirm that it renders.
Some contexts refuse data URLs. A Content Security Policy that lists allowed image sources blocks them unless data: is included in img-src, and support in email clients varies widely, with several stripping or hiding embedded images. Browsers also set maximum lengths for data URLs that differ between engines, so an embedded photograph can fail where an icon succeeds. Test the result where you plan to use it rather than assuming.
Size and privacy: two things the byte-for-byte copy implies
Because the file is not recompressed, the only way to get a smaller data URL is to start with a smaller file. Run the image through the Image Compressor or Image Resizer first, then encode the output. Embedding also removes the browser's ability to cache the image separately from the page, so a logo that appears on every page is better served as a normal file than pasted into each one.
The same byte-for-byte copy means that everything inside the file travels with it. A JPEG straight from a phone carries EXIF metadata that can include the camera model, the capture time and GPS coordinates, and that block is inside the Base64 unchanged. Strip metadata before embedding a photograph in anything public. PNG and WebP files can carry text chunks and colour profiles in the same way.
Limits to know before you rely on it
- The image is encoded exactly as it is. Nothing is resized, compressed or stripped, so a 3 MB photograph becomes about 4 MB of text.
- The media type in the prefix is whatever your browser reports, usually from the extension. An unusual extension can give a wrong or empty type, and the content is never checked.
- A format the browser cannot display, such as HEIC in most desktop browsers, still encodes, but the data URL will not render in an img tag there.
- Metadata inside the file, including JPEG EXIF data with location information, is carried into the Base64 unchanged.
- One file at a time, with no batch mode and no option for the bare Base64 without the data: prefix; remove the prefix by hand if you need only the payload.
- Large files produce very long strings. The text box and the clipboard can become slow with files of tens of megabytes.
Questions people ask about the Image to Base64
How do I use the result in HTML or CSS?
Paste the whole string, starting with data:, as the src of an img element or inside url() in a CSS rule such as background-image. Keep the quotes around the value in CSS. The browser decodes it on the spot and no request is made for a separate file.
Why is the output so much longer than the file size?
Base64 represents every three bytes with four text characters, so the payload is a third larger than the file, and the prefix adds a few more characters, 22 for a PNG. A 30 KB image gives about 40,000 characters. That overhead is why data URLs suit small icons and not photographs.
Can I get just the Base64 without the data: prefix?
Yes, by editing the result: delete everything up to and including the first comma. What remains is the raw Base64 of the file, which is what an API expecting a Base64 image field usually wants. The prefix is only needed where a URL is expected.
Does converting reduce quality or remove transparency?
No. The file is read as bytes and encoded without decoding the image, so nothing is lost: PNG and WebP transparency, GIF animation frames, embedded colour profiles and SVG text are all kept exactly. Decoding the Base64 gives back a file identical to the original.
Is the image uploaded anywhere?
No. The file is read by FileReader inside your browser and the data URL is built there. Nothing is sent to a server or stored by the site, and the result is gone when you close or reload the page. The downloaded text file is created by your browser from the same local string.
Will the data URL work in an email or on every website?
Not everywhere. Many email clients hide or strip embedded images, a Content Security Policy can block data: as an image source, and each browser engine sets its own maximum length for data URLs. For pages you control, allow data: in the policy and keep the images small; for email, a hosted image is more reliable.
Sources and further reading
- MDN Web Docs, Data URLs: the data:[mediatype][;base64],data syntax, the text/plain default and browser length limits
- RFC 2397, The data URL scheme: the formal definition of data URLs
- MDN Web Docs, FileReader.readAsDataURL(): the method used to read the file and produce the data URL
- MDN Web Docs, Base64 glossary entry: how the encoding works and why the output is about a third larger