Image to Base64 Converter
Choose an image to get its Base64 string, a full data URI, an <img> tag and a CSS background-image rule. The Base64 to Image tab does the reverse: paste a string to preview the image and download it.
Image ↔ Base64
Upload Image
Drop an image here or click to browse
PNG, JPG, GIF, WebP, SVG, AVIF - any image type
Output Snippets
Upload an image to see the output
Runs in your browser: your files and text are not uploaded. Free, no account needed.
Last updated: · Reviewed by the QuickTooly Team
Base64 size, syntax and limits
What Base64 does to the file size
Base64 writes every 3 bytes of the file as 4 text characters, so the encoded text is 4/3 of the original, about 33% larger, plus up to two = padding characters. A 30,000-byte PNG becomes 30,000 ÷ 3 × 4 = 40,000 characters. Inside a data URI the data:image/png;base64, prefix adds a few more.
The size panel shows the length of the raw Base64 string and the increase over the original file, about +33%. The data URI, HTML and CSS snippets are longer by their prefix and tags.
Data URI syntax
A data URI has the form data:[media type][;base64],[data], for example data:image/png;base64,iVBORw0KGgo…. The tool takes the media type from the file, so check that it is right before you paste the snippet. The HTML snippet uses alt="image"; replace it with a real description.
SVG does not need Base64. As text it can go into a data URI URL-encoded (data:image/svg+xml,%3Csvg…), which is usually shorter than the Base64 version.
When inlining is a bad idea
- Large images: the encoded text is a third bigger and is part of the HTML or CSS file, so the page or stylesheet must download in full before it can be used.
- Images used on many pages: a separate image file is cached once; an inlined one is downloaded again inside every page that contains it.
- Images that change: any edit to the image changes the HTML or CSS file too, which invalidates its cache.
- Responsive images: a data URI is one fixed file, so you lose srcset and per-screen sizes.
Inlining fits small, rarely changing images such as a few icons or a tiny placeholder, and places where a separate file is not possible, such as a single-file HTML report or a JSON payload.
Decoding Base64 back to an image
- Accepted input: a full data URI, or a bare Base64 string. For a bare string the tool guesses the type from the first bytes (JPEG, PNG, GIF, WebP or SVG) and falls back to PNG.
- URL-safe Base64: a string that uses
-and_instead of+and/, or that has its=padding removed, is converted to standard Base64 before decoding. - Rejected input: data URIs that are not Base64 encoded (no
;base64), and strings with characters outside the Base64 alphabet. - Download name: the file is saved as "decoded-image" with an extension from the media type, for example decoded-image.png or decoded-image.jpg.
Image to Base64 questions
Is there a file size limit?
The code sets no limit. The file is read into memory and the full Base64 text is placed in the page, so very large images make the page slow and the output impractical to paste.
What happens if I pick a file that is not an image?
The tool only accepts files whose type the browser reports as image/*. For any other file, including image formats the browser does not recognize, it shows a message under the upload area and keeps the previous result.
Is Base64 a form of encryption or compression?
Neither. Anyone can decode it, and it makes the data larger. Compress the image before encoding if size matters.
Related image tools
- Image Compressor: shrink the file before encoding, since Base64 adds a third on top of its size.
- SVG Optimizer: clean up an SVG before you inline it.
- WebP Converter: a smaller format to start from when the target browsers support WebP.