🔐Base64 Encode / Decode
Encode text or data to Base64 format or decode Base64 back to plain text. Supports UTF-8 and multi-line Base64 strings. All encoding and decoding is performed locally in your browser — no data is transmitted over the internet.
Prefer to skip the form? Scroll down and Ask AI Instead. Just describe your situation and let AI handle the math for you in seconds.
Result
SGVsbG8sIFdvcmxkIQ==
Input vs Output Length
✦ Ask AI Instead
Base64 Encoder / Decoder: How It Works and When to Use It
Base64 is a binary-to-text encoding that converts any data into a sequence of 64 printable ASCII characters (A–Z, a–z, 0–9, +, /). It encodes 3 bytes of binary data into 4 characters, increasing size by about 33%. Hello → SGVsbG8=. All processing happens in your browser — nothing is sent to any server.
Size formula: Output chars = ⌈Input bytes / 3⌉ × 4 — always a multiple of 4, padded with = if needed
| Common Use | Example | Why Base64 |
|---|---|---|
| Email attachments | MIME encoding | SMTP is text-only |
| Data URIs | data:image/png;base64,… | Embed images in HTML |
| JWT tokens | eyJhbGciOiJIUzI1… | URL-safe token transport |
Base64 is one of the most fundamental encoding schemes in computing. It appears in email, web APIs, authentication headers, configuration files, and cryptographic key storage — essentially anywhere binary data needs to travel through a text-only transport layer.
How Base64 Encoding Works
Base64 takes every 3 bytes (24 bits) of input and splits them into four 6-bit groups. Each 6-bit value (0–63) maps to a character in the Base64 alphabet: 0=A, 1=B, …, 25=Z, 26=a, …, 51=z, 52=0, …, 61=9, 62=+, 63=/. If the input length is not divisible by 3, padding characters (=) are added to make the output length a multiple of 4. A single trailing byte gets encoded as two Base64 chars plus ==; two trailing bytes become three chars plus =.
Base64 vs Encryption
Base64 is NOT encryption. It is a reversible encoding — anyone can decode Base64 without a key. Never use Base64 to "hide" sensitive data like passwords or API keys. Base64-encoded data is just as readable as plaintext to anyone who recognizes it. For security, use proper encryption (AES, RSA) or hashing (bcrypt, SHA-256). Base64 is appropriate for data transport and storage format compatibility, not for security.
Frequently Asked Questions
What is Base64 encoding used for?
Base64 is used to encode binary data (images, files, binary protocols) into printable ASCII text so it can travel through text-only channels. Common uses: (1) Email attachments — SMTP was designed for 7-bit ASCII text, so all attachments are Base64-encoded before transmission. (2) Data URIs — embedding images directly in HTML/CSS: <img src="data:image/png;base64,iVBOR…">. (3) JWT tokens — the header and payload sections of JSON Web Tokens are Base64url-encoded. (4) HTTP Basic Auth — "user:password" is Base64-encoded in the Authorization header. (5) Storing binary data in JSON, XML, or databases that only support text fields.
Is Base64 encoding the same as encryption?
No. Base64 is an encoding scheme, not encryption. Encoding is reversible without any key — anyone who sees Base64 data can decode it instantly. Encryption scrambles data using a secret key so only authorized parties can read it. Base64-encoded text is immediately recognizable by the trailing = signs and the limited character set. Never use Base64 to protect sensitive data like passwords, credit card numbers, or personal information. For security, use proper encryption (AES-256, RSA) or one-way hashing (bcrypt, Argon2) depending on the use case.
Why does Base64 add about 33% to the file size?
Base64 encodes 3 bytes of binary data (24 bits) into 4 ASCII characters (32 bits). The ratio is 4/3 ≈ 1.333, meaning every 3 bytes becomes 4 bytes — a 33.3% size increase. For a 1 MB image, the Base64 version is about 1.33 MB. This overhead is an acceptable cost when binary data must travel over text-only channels. Base64url (used in JWTs and URLs) replaces + with - and / with _ to avoid URL encoding issues, but has the same size overhead.
How do I decode a Base64 string?
To decode Base64: paste the Base64 string into the input field, select "Decode" as the operation, and click calculate. Valid Base64 strings contain only A–Z, a–z, 0–9, +, / characters and end with 0, 1, or 2 = padding characters. The total length must be a multiple of 4. In JavaScript: atob("SGVsbG8=") returns "Hello". In Python: import base64; base64.b64decode("SGVsbG8="). In command line: echo "SGVsbG8=" | base64 -d. Note: Base64url strings (used in JWTs) use - and _ instead of + and / — replace these before decoding with standard Base64.