Encode & decode Base64 instantly. No ads. No tracking.

INPUT
Drop a file here or click to browse
Supports images, PDFs, and any binary file
Preview of uploaded image
image.png 0 KB
OUTPUT
Ready
encode   decode   ? help

What is Base64 Encoding?

Base64 is a binary-to-text encoding scheme that converts binary data into a sequence of printable ASCII characters. It uses a set of 64 characters — A-Z, a-z, 0-9, +, and / — to represent data, with = used for padding. This makes it safe to transmit binary data over protocols that only support text, like HTTP, SMTP (email), and JSON or XML payloads.

The encoding works by taking every 3 bytes (24 bits) of input and splitting them into four 6-bit groups, each mapped to one of the 64 characters. This means Base64-encoded data is always about 33% larger than the original — a tradeoff for transport safety.

How to Encode and Decode Base64

With base64.dev, just paste your text and the tool auto-detects whether to encode or decode. No buttons to click. If you want to force a direction, use the keyboard shortcuts: Cmd+Enter to encode, Cmd+Shift+Enter to decode.

Base64 in JavaScript

JavaScript provides built-in functions for Base64:

// Encode
const encoded = btoa("Hello, world!");
// "SGVsbG8sIHdvcmxkIQ=="

// Decode
const decoded = atob("SGVsbG8sIHdvcmxkIQ==");
// "Hello, world!"

Note that btoa() and atob() only handle Latin-1 characters. For Unicode strings, encode to UTF-8 first using TextEncoder and TextDecoder.

Base64 in Python

import base64

# Encode
encoded = base64.b64encode(b"Hello, world!")
# b'SGVsbG8sIHdvcmxkIQ=='

# Decode
decoded = base64.b64decode(encoded)
# b'Hello, world!'

URL-Safe Base64 (RFC 4648)

Standard Base64 uses + and / which have special meaning in URLs. URL-safe Base64 (defined in RFC 4648 Section 5) replaces + with - and / with _, and typically omits the = padding. This is commonly used in JWTs, URL parameters, and filenames. Switch to the "URL Safe" tab above to use this variant.

Image to Base64 Data URI

You can embed images directly in HTML or CSS using Base64 data URIs. The format is data:image/png;base64,... — switch to the "Image" tab above, drop your image, and get the data URI ready to paste into your code. This eliminates an extra HTTP request, though it increases the HTML/CSS size by ~33%.

Common Use Cases for Base64

Base64 encoding is used in email attachments (MIME), embedding images in HTML/CSS (data URIs), encoding binary data in JSON APIs, storing cryptographic keys and certificates (PEM format), JSON Web Tokens (JWT), and encoding query parameters in URLs. Anywhere you need to pass binary data through a text-only channel, Base64 is the standard solution.