Base64 Image Converter
Utility Workspace

Base64 Image Converter

Convert images to Base64 and Base64 to images

Client-sideImage SupportInstant

Drop an image here, or click to browse

PNG, JPG, GIF, SVG, WebP, BMP • Max 10 MB

Format:
Developer Snippets

Ready-to-use examples in multiple languages

Switch between snippets, inspect the highlighted code, and copy the version that fits your stack.

Code Preview

Python

python13 lines
import base64

# ── Image → Base64 ──
with open("logo.png", "rb") as f:
    encoded = base64.b64encode(f.read()).decode("utf-8")

# With data URI prefix
data_uri = f"data:image/png;base64,{encoded}"
print(data_uri[:80], "...")

# ── Base64 → Image ──
with open("output.png", "wb") as f:
    f.write(base64.b64decode(encoded))
Tool Guide

What is Base64 Image Encoding?

Base64 image encoding converts binary image data (PNG, JPEG, etc.) into a plain ASCII string. This is commonly used to embed images directly in HTML, CSS, JSON, or XML documents without requiring a separate file. The resulting string is approximately 33% larger than the original binary data, but it eliminates additional HTTP requests and simplifies data transport in text-based protocols.
Practical Flow

How to Use This Tool

  1. 1
    Upload Image: Drag and drop an image or click to browse. Supports PNG, JPG, GIF, SVG, WebP, and BMP up to 10 MB.
  2. 2
    Choose Format: Select 'Raw Base64' for just the encoded payload, or 'Data URI' for a complete data:image/… string ready for HTML/CSS.
  3. 3
    Copy or Download: Copy the result to your clipboard, or download it as a .txt file.
  4. 4
    Decode: Switch to 'Base64 → Image' mode to paste a Base64 string and see the rendered image with download option.
Reference

Example

A 48 KB PNG image encodes to approximately 64 KB of Base64 text. The Data URI format would look like: data:image/png;base64,iVBORw0KGgo…
Keep In Mind

Important Note

Base64 encoding increases data size by ~33%. For large images, it's usually better to serve the file directly. Base64 embedding is most useful for small icons, logos, and images under 50 KB where reducing HTTP requests is more important than payload size.