Image to Data URI
Get a data: URI for any image, ready to paste directly into an <img src> or CSS background-image. All processing runs in your browser.
Drop an image here
or click to browse
BASE64
Converts an image to a full data URI (with MIME type prefix) ready to embed in HTML or CSS.
How it works
By default the data URI is built from a copy of a JPEG, PNG, WebP, or GIF image with the camera and editing metadata removed (EXIF including GPS, XMP, IPTC, comments, and C2PA), keeping its orientation; the Keep original metadata option encodes the file exactly as it is, and other formats are encoded unchanged with a note. FileReader.readAsDataURL then asks the browser to wrap the bytes in a data: URI for you. Internally it base64-encodes the payload using the same algorithm as btoa() and prefixes the result with the file's MIME type (for example 'data:image/png;base64,...'). The returned string can be pasted directly into an <img src> attribute or a CSS background-image rule.
Processing runs in your browser
All encoding and decoding happens inside your browser tab. Our servers are not involved at any point. You can confirm this yourself in your browser's DevTools Network tab.
Technical specification
Base64 is specified in RFC 4648 (IETF, 2006). The encoding groups every three input bytes (24 bits) into four 6-bit values, each mapped to a printable ASCII character from a 64-character alphabet (A–Z a–z 0–9 + /). If the input length is not divisible by 3, one or two = padding characters are appended. The URL-safe variant (RFC 4648 §5) replaces + with - and / with _, making it safe for use in URLs and HTTP headers without further percent-encoding. This tool decodes URL-safe input but always encodes with the standard alphabet, as data URIs do.
- Standard
- RFC 4648. The Base16, Base32, and Base64 Data Encodings
- Size overhead
- ~33% overhead (every 3 bytes becomes 4 characters)
- Alphabet (standard)
A–Z a–z 0–9 + /with=padding- Alphabet (URL-safe)
A–Z a–z 0–9 - _(used in JWTs; accepted when decoding)
Related operations
To compute SHA hashes of text or files, or MD5 of text, use the hash generator. For percent-encoding query strings or URL paths, try URL encode. To decode signed tokens that wrap Base64 payloads, see the JWT decoder. To switch the same image between a data URI, raw Base64, and a ready-made CSS background rule, use the image to data URI converter.
Frequently asked questions
- What is a data URI?
- A data URI is a Base64-encoded version of a file prefixed with its MIME type, e.g. data:image/png;base64,.... It can be used anywhere a URL is accepted.
- Will embedding images as data URIs affect performance?
- For small images (icons, logos) it can eliminate an HTTP request. For large images it increases HTML size, use sparingly.
- Which image formats are supported?
- JPEG, PNG, WebP, GIF, SVG, and any format your browser can read. Metadata is removed by default from JPEG, PNG, WebP, and GIF; other formats are encoded unchanged, and the tool notes it. File to Base64 mode always encodes the exact bytes.
- Is my image sent to a server?
- All processing runs in your browser. The image is read with the FileReader API and the data URI is built locally. Our servers are not involved at any point.
- Is there a file size limit?
- Images up to 10 MB are accepted. A larger file is rejected with a message before it is read.
Last reviewed September 30, 2026
Other pages for this tool
Related tools
- Background reading: Complete guide to data tools