Base64 Encoder / Decoder
Encode text to Base64 or decode Base64 strings back to plain text. Supports UTF-8 and URL-safe Base64 variants. Essential developer tool for data encoding.
Input Length
13 chars
Output Length
20 chars
About the Base64 Encoder / Decoder
A Base64 encoder and decoder converts text or binary data to and from Base64 format — an encoding scheme that represents binary data using only 64 printable ASCII characters (A-Z, a-z, 0-9, +, /). Base64 was designed to safely transmit binary data through channels that can only handle text, such as email systems, HTML attributes, JSON strings, and XML documents. It is not encryption — Base64 is trivially reversible and provides no confidentiality — but it is ubiquitous in web development and data exchange. Common uses include embedding images in HTML as data URIs (data:image/png;base64,...), encoding email attachments in MIME format, encoding credentials in HTTP Basic Authentication headers (Authorization: Basic base64(user:pass)), and forming the payload section of JSON Web Tokens (JWTs). The URL-safe variant replaces + with - and / with _ to avoid encoding issues in URLs and filenames. This tool is used by web developers, API developers, security professionals, and anyone working with encoded data.
Formula
3 bytes (24 bits) → 4 Base64 chars (6 bits each) | Output length = ceil(input_bytes / 3) × 4 | URL-safe: + → - and / → _
How It Works
Base64 processes input in 3-byte (24-bit) blocks and converts each block to 4 Base64 characters (6 bits each): 24 bits → 4 × 6 bits. The 64 printable characters represent values 0-63: A=0, B=1, ..., Z=25, a=26, ..., z=51, 0=52, ..., 9=61, +=62, /=63. If the input length is not a multiple of 3, padding characters (=) are added: 1 remaining byte → 2 Base64 chars + "=="; 2 remaining bytes → 3 Base64 chars + "=". Size expansion: every 3 bytes become 4 characters → 33% size increase. For example, "Man" (ASCII 77, 97, 110 → binary 01001101 01100001 01101110) → Base64 TWFu. Encoding in JavaScript: btoa(unescape(encodeURIComponent(str))) handles multi-byte UTF-8. Decoding: decodeURIComponent(escape(atob(base64str))). URL-safe Base64: replace + → - and / → _, and optionally remove = padding.
Tips & Best Practices
- ✓Base64 is not encryption. Any developer who recognises "==" at the end of a string immediately knows it is Base64 and can decode it in seconds. Never use Base64 to protect sensitive data — use proper symmetric (AES-256) or asymmetric (RSA/ECC) encryption.
- ✓Data URIs for images: "data:image/png;base64,[encoded data]" can embed images directly in HTML/CSS without a network request. This is useful for small icons and logos, but large images should remain separate files — a 100KB image becomes a 133KB string that bloats your HTML and cannot be cached separately.
- ✓JWT tokens use Base64URL encoding (not standard Base64) for all three sections (header, payload, signature). The payload is Base64URL-decoded to read the claims — but the signature must still be validated cryptographically. Never trust JWT payload data without verifying the signature against the secret or public key.
- ✓Line length: many legacy Base64 implementations (PEM certificate format, MIME email) wrap lines at 76 or 64 characters with CRLF line endings. Modern web implementations (btoa, data URIs) do not add line breaks. When interoperating with legacy systems, check whether line wrapping is expected.
Who Uses This Calculator
Web developers encoding and decoding data URIs, authentication headers, and JWT payloads during development and debugging. API developers checking encoded request and response payloads. Security professionals inspecting Base64-encoded data in network traffic, JWT tokens, and authentication headers. Students and developers learning about data encoding, web protocols, and authentication mechanisms.
Optimised for: USA · UK · Canada · Australia · Calculations run in your browser · No data stored
Frequently Asked Questions
What is Base64 encoding used for?
Base64 encodes binary data as ASCII text, enabling safe transmission through text-only channels. Common uses: embedding images in HTML/CSS as data URIs, encoding email attachments (MIME), storing binary data in JSON or XML, HTTP Basic Authentication credentials, and JWT token payloads.
How does Base64 work?
Base64 converts every 3 bytes (24 bits) of binary data into 4 ASCII characters from a 64-character alphabet (A-Z, a-z, 0-9, +, /). This expands the data by 33%. For strings not divisible by 3, padding characters (=) are added. URL-safe Base64 replaces + with - and / with _ to avoid encoding issues in URLs.
Is Base64 encoding the same as encryption?
No. Base64 is encoding, not encryption — it is trivially reversible by anyone who recognizes it. Never use Base64 to secure sensitive data. For security, use proper encryption (AES-256) with a secret key. Base64 is purely for format compatibility, not confidentiality.