Base64 Encoder & Decoder
Convert any text to Base64 and back. UTF-8 safe and RFC 4648 compliant. Runs entirely in your browser.
What Base64 is for
Base64 is a binary-to-text encoding scheme that maps every three bytes of binary input into four ASCII characters drawn from a fixed alphabet (A-Z, a-z, 0-9, +, /, with = as padding). It exists because many of the protocols and formats engineers work with — email, HTTP headers, JSON, URL parameters — are text-only and cannot safely carry arbitrary bytes.
Base64 is not encryption. The transformation is fully reversible without any key and adds about 33% overhead compared to the raw bytes. Use it when you need to transport binary data through a text channel, not when you need to keep it secret.
How the encoding works
Each character in the Base64 alphabet encodes 6 bits, so 4 characters carry exactly 24 bits — three 8-bit bytes. When the input length isn't a multiple of three, the encoder pads the output with one or two = characters to keep alignment. The decoder reverses this: it strips padding, maps each character back to 6 bits, and reassembles the bytes.
The original Base64 alphabet is unsafe for URLs (+ and / have special meaning in URLs and filenames). A variant called base64url uses - and _ instead and is the variant used inside JWTs.
Common use cases
- Embedding small images. The
data:URI scheme uses Base64 to inline images in HTML and CSS. - HTTP Basic authentication. The
Authorization: Basic <b64>header encodesusername:passwordas Base64. - JWTs and signed tokens. Header, payload, and signature are each base64url-encoded.
- Email attachments. MIME uses Base64 to ship binary attachments inside text-only SMTP messages.
- API payloads carrying binary. APIs that exchange JSON often Base64-encode binary fields like keys, certificates, or images.
Base64 is not security. Anyone can decode it instantly. Never store secrets or credentials Base64-encoded thinking it provides protection. Encrypt sensitive data with an algorithm like AES-GCM (see Symmetric vs Asymmetric Encryption).
FAQ
Why does Base64 add 33% overhead?
Three 8-bit bytes (24 bits) are encoded as four 6-bit characters (24 bits represented in 32 bits, since each ASCII character takes a full byte). That's a 4-to-3 ratio, or about 33% expansion.
What's the difference between Base64 and base64url?
Standard Base64 uses + and /; base64url replaces them with - and _ and usually omits padding. base64url is the variant required by JWTs and many URL-bearing tokens.
Does this handle UTF-8 input correctly?
Yes. The tool encodes via TextEncoder, which produces UTF-8 bytes before Base64 encoding. Decoding reverses that with TextDecoder.
Can I encode files in the browser?
This tool focuses on text. For files, modern browsers expose FileReader.readAsDataURL() which produces a Base64 data URI from any file.