Image to Base64 Converter – Free Online Tool | NerdyTools
🖼 Image & Developer Tools

Image to Base64 Converter

Use this free image to Base64 converter to turn an image into a Base64 string, Data URI, CSS background value, HTML img tag, or JSON payload. The conversion runs in your browser, so the image you select is not uploaded.

🖼

Image to Base64 Converter

Drop your image below or click to browse. Your file never leaves your device.

📁

Drop your image here

or click to browse your files

JPG · PNG · GIF · WebP · SVG · BMP · ICO · Max 10 MB

Converting…

Preview
Output Format
Data URI
🔄

Base64 to Image (Reverse)

Paste a Base64 string or Data URI to preview and download the decoded image.

What Is Base64 Encoding?

Base64 is a binary-to-text encoding scheme that represents binary data — such as image files — as a string of ASCII characters. It was originally designed to allow binary data to be safely transmitted over systems built to handle text only, such as email (MIME) and HTTP headers. The name comes from the fact that it uses 64 printable characters (A–Z, a–z, 0–9, +, and /) to represent binary data.

Every 3 bytes of binary data are encoded into 4 Base64 characters. This means Base64 encoding increases data size by approximately 33% — a 100 KB image becomes roughly 133 KB as a Base64 string. Despite the size overhead, Base64 is extremely useful in web development because it allows binary files to be embedded directly into text-based formats like HTML, CSS, JSON, and XML.

Base64 encoding ratio: 3 bytes binary → 4 ASCII characters Size increase: ~33% larger than originalExample: M (0x4D) a (0x61) n (0x6E) → 010011 010110 000101 101110 → T W F u → "TWFu"

Output Formats Explained

Data URI

Embeds the Base64 string directly into a URL: data:[mediatype];base64,[data]. Can be used anywhere a regular URL is accepted — HTML src attributes, CSS url() values, JavaScript, and more.

Raw Base64

The encoded string without any prefix. Useful for storing in databases, passing through APIs, or using in systems that add their own prefix.

CSS Background

Formats as a complete CSS background-image property. Paste directly into any CSS file to embed the image without a separate HTTP request.

HTML img Tag

Wraps the Data URI in a complete HTML img element with src, alt, width, and height attributes pre-filled. Paste directly into any HTML file.

JSON

Outputs the image as a JSON object with the Base64 data as a string value — suitable for API payloads and JSON-based data transfer.

When to Use Base64 Images

  • Small icons and logos under ~5 KB where the HTTP request overhead exceeds the 33% size penalty.
  • Email HTML templates — many email clients block externally hosted images but display Base64-embedded ones correctly.
  • API payloads — transmit an image alongside other data in a single JSON request.
  • Offline / PWA applications — embed images as Base64 to ensure availability without a network connection.

When NOT to Use Base64

Avoid Base64 for large images (over 10–20 KB). The 33% size increase outweighs the saved HTTP request, and Base64 strings cannot be cached by the browser separately from the HTML or CSS file they are embedded in. For most production websites, CDN-hosted images are the right choice for anything larger than a small icon.

Frequently Asked Questions

What image formats does this converter support?
All formats your browser can read: JPG/JPEG, PNG, GIF (including animated), WebP, SVG, BMP, ICO, TIFF, and AVIF. The output Base64 string will include the correct MIME type automatically.
Why is my Base64 string so long?
Base64 increases data size by approximately 33%. A 100 KB image produces a Base64 string of roughly 133 KB (about 136,000 characters). This is normal — there is no compression involved in Base64 encoding.
Can I use a Base64 image directly in HTML?
Yes. Select the HTML img tag format to get a complete img element with the Data URI as the src attribute. Paste directly into any HTML file and the image displays without any external file or HTTP request.
Can I use a Base64 image in CSS?
Yes. Select the CSS Background format to get a ready-to-paste background-image property that works in both inline styles and external CSS files.
Does Base64 encoding compress my image?
No. Base64 always makes data larger (by about 33%), not smaller. If you need to reduce image file size, compress the image before converting to Base64.
What is the maximum file size I can convert?
This tool supports images up to 10 MB. For production use, images embedded as Base64 should ideally be kept under 5–10 KB.
How do I decode a Base64 string back to an image?
Use the Base64 to Image section above — paste your Base64 string or Data URI and click Preview to see the decoded image, then download it.
Why does Base64 end with equals signs (=)?
The = sign is padding. Base64 encodes 3 bytes at a time into 4 characters. If input data is not a multiple of 3 bytes, padding characters are added to make the output a multiple of 4.
Can I send Base64 images through an API?
Yes. Use the JSON output format to get a properly structured JSON object containing your Base64-encoded image. Many APIs — including AI vision and document processing APIs — accept images as Base64 strings in JSON request bodies.
Will Base64 images slow down my website?
They can for large images. Base64 strings cannot be cached independently — they re-download every time the HTML or CSS file containing them loads. For images over 10 KB used across multiple pages, externally hosted images with cache headers will always be faster.
Is my image private when I use this tool?
Completely. Your image is read and converted locally using the FileReader API. It is never uploaded to any server, never stored, and never transmitted anywhere.
⚠️
Oops!
Please select an image file first.
Scroll to Top