Image to Base64 Converter
Convert an image to a Base64 data URI and get ready-to-paste HTML, CSS, Markdown and JSON snippets. The file is read locally in your browser and never uploaded.
Drop an image here, or click to browse
PNG, JPEG, GIF, WebP, SVG, AVIF, ICO… — max 10 MB
Why convert an image to Base64?
Sometimes you cannot, or do not want to, reference an image as a separate file. An HTML email should not depend on remote images that clients block by default; a single-file prototype or CodePen demo is easier to share with everything inline; an API may expect an image as a string inside JSON; and a tiny icon in a stylesheet saves a request. In all these cases you need the image as Base64 text, usually wrapped in a data: URI.
This converter reads the file in your browser and gives you the data URI, the bare Base64 and four ready-made snippets, so you can paste the result straight into your code without hand-editing quotes or prefixes.
How to use it
- Drop an image on the upload area, or click it (or press Enter) to choose a file.
- Check the preview and details: MIME type, pixel dimensions, original size and data URI length.
- Choose an output tab — Data URI, Raw Base64, HTML <img>, CSS background-image, Markdown or JSON.
- Click Copy or Download .txt. Remove image resets the tool.
Worked example
Uploading a 16×16 PNG called check-icon.png produces snippets like these (the Base64 is shortened here):
<img src="data:image/png;base64,iVBORw0KGgo…" alt="check icon" width="16" height="16" />
background-image: url("data:image/png;base64,iVBORw0KGgo…");
The alt text is derived from the file name (dashes and underscores become spaces), and the width/height attributes come from the real image so the browser can reserve space and avoid layout shift. Edit the alt text to describe the image properly before publishing.
What each output is for
- Data URI — the complete
data:image/…;base64,…string, usable wherever a URL is accepted. - Raw Base64 — only the encoded bytes, for APIs that ask for a Base64 field and a separate MIME type.
- HTML <img> — an image tag with alt text and intrinsic dimensions.
- CSS background-image — a declaration with the URI quoted, which is required for SVG data that contains spaces or quotes.
- Markdown — image syntax; note that GitHub and some other renderers block data URIs in Markdown.
- JSON — an object with file name, MIME type and Base64 data, a common shape for upload APIs.
Limitations
Files are limited to 10 MB, and anything over a few hundred kilobytes produces strings that editors and browsers handle slowly. The tool does not resize or compress — it encodes the exact bytes you provide, so shrink large images first. Dimensions are unavailable for formats your browser cannot display. Some email clients (notably several versions of Outlook and Gmail) do not display data URI images, so test before relying on them in email.
Tips
- Inline only small images (icons, logos, placeholders); serve larger ones as normal cacheable files.
- Reduce the file before encoding with the image compressor.
- To check a Base64 string someone sent you, paste it into Base64 to Image.
Frequently Asked Questions
What is a Base64 data URI?
A data URI puts a file's bytes directly inside a URL, in the form data:[mime-type];base64,[data]. Browsers treat it like any other image URL, so it works in <img src>, CSS url() and Markdown without a separate file.
Is my image uploaded to a server?
No. The image is read with the browser's FileReader API and converted on your device. Nothing is uploaded.
Which image formats are supported?
Any image type your browser recognises, including PNG, JPEG, GIF, WebP, SVG, AVIF, BMP and ICO, up to 10 MB. The data URI keeps the original MIME type; the file is not recompressed or converted.
Why is the Base64 output bigger than the image?
Base64 represents every 3 bytes with 4 characters, so the text is about 33% larger than the file. Gzip or Brotli on your server claws back only part of that overhead.
When should I avoid inlining images as Base64?
Avoid it for large or frequently reused images. An inlined image cannot be cached separately, is downloaded again with every page or stylesheet that contains it, and makes your HTML or CSS heavier to parse. It suits small icons, email templates and single-file demos.
Related tools
- Base64 Encoder/DecoderEncode and decode Base64 strings online
- JWT Decoder & ValidatorDecode JSON Web Tokens (JWT) and inspect their header, payload, claims, and expiry status.
- URL Encoder / DecoderEncode or decode URLs and query string parameters using percent-encoding (RFC 3986).
- Base64 to Image DecoderDecode Base64 strings back to images. Preview the image live and download it as PNG, JPEG, or WebP.
- HTML Entities EncoderEncode and decode HTML entities
- Base32 Encoder/DecoderEncode and decode Base32 strings online
Found a bug or a wrong result? Report it.