Tools

Home
JSON FormatterSQL FormatterJS ValidatorMinify CSS
Merge PDFCompress PDFImage to PDF
JPG to PNGPNG to WebPCrop Image

Change Image To Base64

Upload an image and convert it to a Base64 encoded string. Copy raw Base64 or data URI format. View encoded string size.

Your files never leave your browser
Drop image here or click to upload
Supports JPG, PNG, WebP, GIF, BMP, SVG (max 50 MB)
Preview

Raw Base64 String

Original size:
Base64 size:
Increase:

Data URI Format

Data URI size:
MIME type:

Drop a PNG, JPG, SVG, GIF, or WebP and get both the raw Base64 string and a ready-to-paste data URI back. Size stats are shown too, so you know the ~33% overhead before you inline it into HTML, CSS, or a JSON payload. And everything runs in your browser. Nothing gets uploaded.

How It Works

Drop Image File
➔
FileReader Encodes
➔
Copy Base64 / Data URI

Your browser's FileReader API reads the image as a data URL, which already contains the Base64-encoded version of the file. The tool splits that into the raw Base64 string and the full data URI (with the data:image/...;base64, prefix). It also calculates file sizes so you can see the ~33% overhead that Base64 adds.

Examples

Embedding a Favicon in an HTML File

You have a 1KB favicon.ico and want to inline it so the page loads with zero extra requests.

INPUT
favicon.ico (1.1 KB, image/x-icon)
OUTPUT
data:image/x-icon;base64,AAABAAEAEBAAAAEAIABo... (~1.5 KB data URI, paste into <link href="...">)

Inlining a Logo in a CSS Background

Your stylesheet references a 4KB PNG logo, but the CDN is flaky. Inline it instead.

INPUT
logo.png (4.2 KB, 120x40 px)
OUTPUT
Raw Base64: iVBORw0KGgoAAAANSUhEUgA... (5.6 KB — use in background-image: url(data:image/png;base64,...))

Sending a Screenshot via JSON API

You're building a bug-reporting tool and need to send a screenshot as part of a JSON payload. Binary doesn't work in JSON, so Base64 it is.

INPUT
screenshot.jpg (87 KB, 1280x720 px, image/jpeg)
OUTPUT
Raw Base64: /9j/4AAQSkZJRgABAQAAAQABAAD... (116 KB string — drop into {"image": "..."} in your API call)

Who Uses This

💻 Frontend Developers

Inline small icons and sprites into HTML/CSS to cut HTTP requests on performance-critical pages.

✉ Email Developers

Embed logos directly in email templates so images show up even when external loading is blocked.

🔨 API Engineers

Encode images as Base64 to pass them inside JSON payloads without dealing with multipart form data.

🎓 Students

Quick way to grab a Base64 string for assignments, CodePen demos, or single-file HTML projects.

Common Mistakes

Encoding large images as Base64 for web pages

A 500KB photo becomes ~670KB of Base64 text baked into your HTML. The browser can't cache it separately, and the page payload balloons. Keep Base64 for images under 10-20KB. Anything bigger should stay as a regular file.

Copying the data URI when the API expects raw Base64

The data:image/png;base64, prefix is part of the data URI format — not part of the encoded data itself. If you paste the full data URI into an API field that expects plain Base64, decoding will fail. Grab the raw string instead.

Forgetting to set the correct MIME type

If you manually construct a data URI but use image/png for a JPEG file, some renderers will choke. This tool detects the MIME type automatically, but double-check when building URIs by hand.

Technical Details

Frequently Asked Questions

How do I convert an image to Base64 in HTML?

Drop your image into this tool, then copy the data URI output. Paste it directly into an <img src="data:image/png;base64,..."> tag. That's it — the image is now embedded in the HTML itself with no external file needed.

Does Base64 encoding affect image quality?

No. Base64 is a lossless encoding — it just represents the same binary data as text characters. The decoded output is byte-for-byte identical to the original file. Quality loss only happens if you re-compress the image (like converting PNG to JPEG), which this tool does not do.

Can I use Base64 images in CSS?

Yes. Copy the data URI and paste it into background-image: url(data:image/png;base64,...). Works well for small UI elements like icons and patterns. For anything over 10KB or so, a regular image file will perform better because the browser can cache it separately.

Why is my Base64 string so long?

Base64 inflates data by about a third. A 75KB image produces a ~100KB string. That's just how the encoding works — every 3 bytes become 4 characters. If the string is too large for your use case, consider compressing or resizing the image first before converting.

Is it safe to convert images to Base64 online?

With this tool, yes. Everything runs in your browser — the image never leaves your device. No upload, no server processing, no storage. Other online converters might upload your file to their servers, so always check. Here, you can even disconnect from the internet after the page loads and the tool still works.

Share: