Images Base64 Client-side

Image ⇄ Base64 Converter

Convert images to Base64 (data URLs or raw) and Base64 back to images. Everything runs locally in your browser.

Image
Drop an image here or
No image selected
Preview
Size: 0 · Dimensions:
Base64 Output
Base64
Ready
Image Preview
Decoded preview
MIME: · Size: 0 · Dimensions:

Base64 in popular programming languages

Short, practical snippets + official docs.

Node.js
Docs
const fs = require('fs');
// Encode file to base64
const b64 = fs.readFileSync('in.png').toString('base64');
// Decode base64 to file
fs.writeFileSync('out.png', Buffer.from(b64, 'base64'));
Browser JS
Docs
const file = input.files[0];
const r = new FileReader();
r.onload = () => console.log(r.result); // data:image/png;base64,....
r.readAsDataURL(file);
Python
Docs
import base64
b64 = base64.b64encode(open('in.png','rb').read()).decode('ascii')
open('out.png','wb').write(base64.b64decode(b64))
PHP
Docs
$b64 = base64_encode(file_get_contents('in.png'));
file_put_contents('out.png', base64_decode($b64, true));
Go
Docs
import ("encoding/base64"; "os")
b, _ := os.ReadFile("in.png")
s := base64.StdEncoding.EncodeToString(b)
d, _ := base64.StdEncoding.DecodeString(s)
_ = os.WriteFile("out.png", d, 0644)
Java
Docs
var bytes = java.nio.file.Files.readAllBytes(java.nio.file.Paths.get("in.png"));
var b64 = java.util.Base64.getEncoder().encodeToString(bytes);
var out = java.util.Base64.getDecoder().decode(b64);
java.nio.file.Files.write(java.nio.file.Paths.get("out.png"), out);
C#
Docs
var b64 = Convert.ToBase64String(File.ReadAllBytes("in.png"));
File.WriteAllBytes("out.png", Convert.FromBase64String(b64));
Ruby
Docs
require "base64"
b64 = Base64.strict_encode64(File.binread("in.png"))
File.binwrite("out.png", Base64.decode64(b64))
Bash
Docs
base64 in.png > out.b64
base64 -d out.b64 > out.png

Learn more about Base64

Base64 FAQ

What is Base64?

A binary-to-text encoding that represents bytes using 64 ASCII characters. Useful for embedding or transporting binary data in text channels.

Does Base64 compress data?

No. It increases size by about ~33% (4 bytes for every 3 input bytes), plus any headers if you use a data URL.

What’s a data URL?

A string like data:image/png;base64,.... that inlines the bytes with a MIME type. This tool can include or strip this prefix.

Is Base64 lossless?

Yes. The encoded string represents the original bytes exactly when decoded.

URL-safe Base64?

A variant that replaces +// with -/_. This tool recognizes and decodes it.

Line breaks/newlines?

Modern Base64 (RFC 4648) doesn’t require line breaks. Some older tools wrap at 76 chars; decoding ignores whitespace.

How big can a data URL be?

Browsers allow fairly large data URLs, but memory and performance will be your practical limits. For very large images, prefer file URLs.

Does Base64 keep EXIF/metadata?

Yes, if you encode the original bytes. Base64 is just a different representation of the same bytes.

Do you upload my images?

No. Everything runs locally in your browser; files never leave your device.