Image to Base64 Converter
Image to Base64 converter for PNG, JPG, SVG, GIF, and WebP. Upload a file or drop it here to convert an image to Base64, then copy the base64 image data URI for HTML, CSS, or JSON. PNG to Base64, JPG to Base64, SVG to Base64, and GIF to Base64 all run locally, so the image is never uploaded.
In WeChat, downloads and image copy may be blocked. If a button does not respond, tap ··· in the top-right corner and choose Open in Browser.
Image file
Drop an image here or browse. Processed in your browser — nothing is uploaded. Max 20 MB.
Preview
Paste Base64 data to see the decoded image here.
Details
- File
- base64box-sample.svg
- MIME type
- image/svg+xml
- Dimensions
- 1200 × 400 px
- Output dimensions
- 1200 × 400 px
- Aspect ratio
- 3 : 1
- Megapixels
- 0.48 MP
- Output format
- SVG
- Source size
- 2.7 KB
- Output size
- 2.7 KB
- Base64 size
- 2.7 KB · 3,660 chars
- Overhead
- 0%
- Output file
- base64box-sample-1200x400.svg
Selected images
Convert (optional)
Keep original leaves the file untouched. PNG keeps transparency; JPEG flattens transparency onto white.
Image to base64 reads a picture file and returns its bytes as a data URI, a CSS rule, an <img> tag or plain Base64, ready to paste into HTML, JSON or a stylesheet, with the file processed in your browser so screenshots and internal assets stay on your device.
It is the most practical way to inline a favicon into a single-file report, to send a logo inside an email signature that cannot load remote images, or to attach a small preview to a JSON record. The page also converts and resizes the picture before encoding, which means the encoded result can be smaller than the original file when a 1280 px cap and quality 85 do the heavy lifting first.
How to use
- Choose an image. Drop a PNG, JPEG, SVG, GIF, WebP or BMP file, or browse for one. Single files are capped at 20 MB. The preview and the details table appear as soon as the browser finishes reading the bytes.
- Convert if needed. Format can stay original or switch to PNG, JPEG or WebP; Quality (70–95%, default 85) applies only to JPEG and WebP; Max width caps the output at 2560, 1920, 1280 or 800 px.
- Pick the output shape. Copy as offers Data URI, Plain Base64, CSS background, HTML
<img>, favicon, iframe, JavaScript, Markdown, JSON and XML. Copy the image to base64 result, or download{name}-base64.txtand the converted image separately.
Format details, compression and data URIs
Each image format brings its own header, its own transparency rules and its own idea of a sensible file size. The notes below cover the three that people encode most often.
PNG to base64 keeps transparency
A PNG begins with the bytes 89 50 4E 47, which appear as iVBORw0KGgo at the start of the Base64 string. Converting to JPEG flattens transparent pixels onto white, so a logo with a transparent background changes appearance even when the dimensions stay the same. Keep the format on original, or choose PNG, when the alpha channel matters. PNG files are often the largest here, so a 20 MB screenshot can hit the cap; converting to WebP at quality 85 is usually the better move.
JPG to base64 and the quality trade
A JPEG starts with FF D8 FF, visible as /9j/4AAQ in the encoded form. Because JPEG is lossy, re-encoding at quality 85 usually shrinks the file, and the overhead figure can turn negative even though Base64 adds a third. A 240 KB photo that re-encodes to 100 KB becomes about 136,000 characters, so the encoded string is smaller than the original file even after the 33% Base64 expansion. The Quality menu is hidden while Format stays on original, because re-encoding without a target format would change bytes for no reason.
SVG to base64, with one rasterisation trap
An SVG is text, and with Keep original plus Original width the tool encodes the original markup and labels it data:image/svg+xml;base64,. Choose a Max width instead and the SVG is drawn to a canvas and exported as PNG, losing infinite scalability but gaining predictable dimensions. Inline the SVG form only when the file is small and contains no external references. Animated formats behave differently: a gif to base64 value keeps its frames only when the format stays original and no width cap is applied.
FAQ
What is a base64 image data uri?
It is a single string that starts with data:image/png;base64, or a matching MIME type and continues with the encoded bytes. A browser can render it wherever it accepts a URL, so an image to base64 data uri can sit inside CSS, HTML or a JSON field without a separate file request.
Does a gif to base64 keep the animation?
Yes. An image to base64 conversion keeps the animation as long as the format stays on original and no width cap is applied. Converting to PNG, JPEG or WebP draws one frame, so a gif to base64 value produced after conversion is static. An animated GIF grows by a third, which makes inlining impractical.
Is my image uploaded anywhere?
No. An image to base64 conversion reads the file with the browser's File API, draws it locally when a resize is requested, and encodes it in memory. Nothing is sent to a server, so private screenshots, unreleased designs and customer photos never leave the device.
Why does the tool say the image is too large?
Single files are limited to 20 MB because the bytes are held in memory. The message reads “This image is too large (max 20 MB).” Resize or compress the picture first, then run the image to base64 on the smaller file; a 1280 px cap brings a camera photo under the limit.
Should I inline every image as Base64?
No. Inline icons, logos and tiny previews, where one fewer request matters. Large photos inflate the HTML, cannot be cached on their own and delay the first paint. Keep big images as files and use the image to base64 output for the few assets that must travel with the document.
Related tools
Base64 to Image is the reverse trip: paste a data URI and get the picture back with a preview, zoom and a download in the detected format. Text to Base64 covers the same alphabet without pixels, and PDF to Base64 Converter does the job for documents. Each page reads files locally, needs no account at all, and the image to base64 output is accepted by the decoders here without editing.