Image to Base64 Converter

Encode any image as a Base64 string or data URI you can embed directly in HTML, CSS, JSON, emails or code. Choose the output format, optionally shrink the image first to keep the string short, and copy or download the result.

  • 100% free
  • No sign-up
  • Private & local
  • Works on mobile
Drop images to encode (or paste with Ctrl+V)or browse files · PNG, JPG, WebP, GIF, SVG, ICO, BMP

"Keep original" with original size encodes the file byte-for-byte (lossless).

Private by design: your files are processed locally in your browser and are never uploaded to any server.

What Is an Image to Base64 Converter?

An image to Base64 converter turns the binary data of an image file into a text string made of letters, numbers and a few symbols. Wrapped in a data URI such as data:image/png;base64,iVBORw0..., that string can be placed directly inside HTML, CSS, JavaScript, JSON, XML, SVG or an email. The browser displays it exactly like a normal image file, but without a separate download request.

Developers use Base64 images to embed small icons and logos, to include images in single-file HTML pages and HTML emails, to store images in JSON APIs and databases, and to avoid extra HTTP requests for critical graphics. This free converter handles one or many images at once and offers six output formats. It can also resize and compress the image before encoding, because Base64 is about a third larger than the original file.

How to Convert an Image to Base64

  1. Add your images: drop them in, browse, or paste with Ctrl+V.
  2. Pick an output format: data URI, raw Base64, CSS, HTML, Markdown or JSON.
  3. Optionally shrink the image by choosing a maximum size and format to keep the string short.
  4. Copy the result or download it as a text file.

Output Formats

FormatExampleUse in
Data URIdata:image/png;base64,iVBOR...Anywhere an image URL is accepted
Raw Base64iVBORw0KGgo...APIs, databases, config files
CSSbackground-image: url("data:...")Stylesheets, icons, patterns
HTML<img src="data:...">Web pages, HTML emails
Markdown![alt](data:...)README files, notes, documentation
JSON{"mime": ..., "base64": ...}APIs and app data

When Should You Use Base64 Images?

Base64 is ideal for small images such as icons, logos, tiny backgrounds and placeholders under about 10 KB. Embedding them saves a network request and guarantees they're available immediately. For large photos it's usually a bad idea: the encoded text is about 33% larger than the file, it can't be cached separately by the browser, and it bloats your HTML or CSS. Keep large images as regular files and use Base64 selectively.

Features

  • Six output formatsData URI, raw, CSS, HTML, Markdown and JSON.
  • Pre-encoding optimisationResize and convert to WebP or JPG for much shorter strings.
  • Lossless optionEncode the original file byte-for-byte.
  • Batch conversionEncode many images at once and copy them all together.
  • Size reportCompare the file size with the encoded string length.
  • PrivateImages are encoded locally and never uploaded.

How Base64 Encoding Works

Computers store images as bytes, which are values from 0 to 255, and many of them are not printable text characters. Base64 solves this by taking the data three bytes (24 bits) at a time and splitting it into four groups of six bits. Each six-bit group (0–63) is mapped to one of 64 safe characters: A–Z, a–z, 0–9, + and /. When the data doesn't divide evenly into threes, one or two = signs are added as padding. That's why Base64 strings often end in = or ==.

A data URI simply adds a short header in front of the Base64 text that tells the browser what kind of file it is, for example data:image/webp;base64,. Browsers decode it on the fly and treat it exactly like an image loaded from a URL.

Performance Tips

  • Inline only small, critical images, such as a logo in the header or an icon sprite, to avoid an extra request on first load.
  • Prefer SVG for simple icons. It is text already and often smaller than a Base64 PNG.
  • Compress first. Converting a PNG photo to WebP before encoding can cut the string by 70% or more.

Tip: the size report under each image shows both the image file size and the final string length, so you can quickly judge whether inlining is worthwhile or a regular image file would be better.

Frequently Asked Questions

Is Base64 encryption?

No. Base64 is an encoding, not encryption. Anyone can decode it, so don't use it to hide sensitive images.

Why is the Base64 string bigger than my image?

Base64 uses 4 text characters for every 3 bytes of data, so it is about 33% larger. Resize or convert to WebP first to reduce it.

How do I use a Base64 image in HTML?

Choose "HTML <img> tag" and paste the result into your page, or put the data URI in any src attribute.

Do Base64 images work in emails?

Many email clients support them, but some (notably Gmail and Outlook) block or strip data URIs. Hosted images or attachments are more reliable for email.

How do I convert Base64 back to an image?

Use our Base64 to Image decoder.

Are my images uploaded?

No. Encoding happens entirely in your browser.