Base64 Encode

Encoding options

Switch to Base64 Decode

Runs entirely in your browser. Your data is never uploaded.

How to encode to Base64

Type or paste text above, or drop a file onto the box, and the Base64 output appears instantly. Turn on URL-safe mode for use in URLs and JWTs, or data URI mode to embed an image directly in HTML or CSS. Files are read locally and never uploaded.

Example

hello encodes to aGVsbG8=; Hello, World! encodes to SGVsbG8sIFdvcmxkIQ==.

How Base64 encoding works

Base64 takes the input 3 bytes (24 bits) at a time and splits them into four 6-bit values. Each value (0–63) maps to one character of the alphabet A–Z a–z 0–9 + /. When the input length is not a multiple of 3, the output is padded with one or two =. Because 3 bytes become 4 characters, Base64 output is about 33% larger than the input.

Encode Base64 from the command line

# Linux / macOS
echo -n 'hello' | base64
# PowerShell
[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes('hello'))
# JavaScript (UTF-8 safe)
btoa(String.fromCharCode(...new TextEncoder().encode('hello')))
# Python
import base64; base64.b64encode(b'hello').decode()

Note: use echo -n; without it the trailing newline is encoded too (aGVsbG8K).

FAQ

Why is Base64 output bigger than the input?

Every 3 bytes become 4 characters, so the output is about 33% larger (plus line breaks in MIME mode).

How do I convert an image to Base64?

Drop the image onto the box and enable "data URI". Copy the result into an <img src="..."> or a CSS url().

What is URL-safe Base64?

A variant that uses - and _ instead of + and / and usually omits =, so the output can go in URLs and file names without escaping.

Can Base64 encode emoji and non-English text?

Yes. Text is converted to UTF-8 bytes first, then encoded.