Base64 Encoder & Decoder
Base64 Encoder & Decoder converts text to Base64 and back in real-time. Base64 is a binary-to-text encoding scheme that represents binary data using 64 ASCII characters (A-Z, a-z, 0-9, +, /). It is essential for embedding binary data in text-based formats like JSON, HTML, and email.
This tool supports both standard Base64 (RFC 4648 §4) and URL-safe Base64 (RFC 4648 §5), which replaces + and / with - and _ for safe use in URLs and filenames. Full UTF-8 and emoji support is included. All processing happens entirely in your browser — your data never leaves your device.
Common uses include encoding images as data URIs, preparing binary data for JSON APIs, generating HTTP Basic Auth headers, and working with JWT tokens. Paste your text on the left to encode, or paste Base64 on the right to decode.
New to Base64? Read our beginner's guide or learn about URL-safe encoding. Scroll down for examples, code snippets, and detailed documentation.
What is Base64 Encoding?
Base64 is a binary-to-text encoding scheme defined in RFC 4648 that converts binary data into a printable ASCII string. It uses a 64-character alphabet consisting of A–Z, a–z, 0–9, plus + and /, with = used as padding. The name “Base64” comes from the fact that it uses 64 distinct characters to represent data.
Base64 encoding is essential whenever binary data needs to travel through channels designed for text. Email attachments (MIME), data URIs in HTML and CSS, HTTP Basic Authentication headers, and JSON or XML payloads all commonly carry Base64-encoded content.
How Base64 Encoding Works
The encoding process takes groups of three input bytes (24 bits total) and splits them into four 6-bit values. Each 6-bit value maps to one of the 64 characters in the alphabet. If the input length is not a multiple of three, the output is padded with one or two = characters so the encoded string length is always a multiple of four.
For example, the text Hi (two bytes, 0x48 0x69) becomes the 16-bit sequence 01001000 01101001. Padded to 18 bits and split into three 6-bit groups — 010010, 000110, 1001xx — these map to S, G, k, followed by a single = pad, giving SGk=.
Standard vs. URL-Safe Base64
Standard Base64 (RFC 4648 §4) uses + and / as its 62nd and 63rd characters. These characters have special meaning in URLs and file paths, so URL-safe Base64 (RFC 4648 §5) replaces them with - and _. URL-safe encoding is the right choice whenever encoded data appears in query parameters, cookies, filenames, or URL path segments.
Common Use Cases
- Data URIs: Embed images, fonts, and other assets directly in HTML or CSS with
data:image/png;base64,... - MIME / Email: Binary attachments are Base64-encoded so they survive text-only email transport.
- HTTP Basic Auth: The
Authorization: Basicheader carriesusername:passwordas Base64. - APIs & JSON: Many REST APIs accept file uploads as Base64 strings inside JSON request bodies.
- JWT Tokens: The header and payload sections of a JWT are Base64url-encoded JSON objects.
Quick Examples
JavaScript:
btoa('Hello') // "SGVsbG8="
atob('SGVsbG8=') // "Hello"Python:
import base64
base64.b64encode(b'Hello') # b'SGVsbG8='
base64.b64decode(b'SGVsbG8=') # b'Hello'Command line:
echo -n 'Hello' | base64 # SGVsbG8=
echo 'SGVsbG8=' | base64 --decode # HelloLimitations
Base64 encoding increases data size by approximately 33% (every 3 bytes become 4 characters). It is not encryption — anyone can decode a Base64 string without a key. Never use Base64 to protect sensitive information; use proper encryption (AES, RSA) instead. Base64 is for safe transport of binary data, not for security.