What is the Base64 Encode & Decode?
The Base64 Encoder & Decoder is a standards-compliant RFC 4648 binary-to-text encoding utility designed for software engineers, API developers, and security analysts. Base64 translates arbitrary 8-bit binary byte streams into a safe 64-character ASCII alphabet (`A–Z`, `a–z`, `0–9`, `+`, `/`, and `=` padding) so that binary payloads, cryptographic signatures, HTTP Basic Auth credentials, Data URLs, and multi-byte Unicode text can travel across text-only protocols like HTTP headers, JSON strings, XML, and SMTP email without corruption.
A common pitfall of many browser-based Base64 tools is that they rely blindly on JavaScript's legacy `window.btoa()` and `window.atob()` functions, which throw a `DOMException: The string to be encoded contains characters outside of the Latin1 range` whenever you enter curly quotes, accented characters (`é`, `ü`), CJK scripts, or emojis (`🚀`). Our tool solves this permanently by routing all input through the modern Web `TextEncoder` and `TextDecoder` APIs, converting strings into canonical UTF-8 `Uint8Array` byte buffers before Base64 serialization.
In addition to standard RFC 4648 Section 4 Base64, the workspace includes a one-click toggle for URL-Safe Base64 (`base64url`, RFC 4648 Section 5)—which replaces `+` with `-`, `/` with `_`, and optionally strips `=` padding for safe inclusion in URLs, filenames, and JWT tokens.
How to Use Base64 Encode & Decode (Step-by-Step)
- 1
Select Encode, Decode, or Live Bidirectional Mode
Type in the Plain Text box to encode to Base64 in real time, or type/paste into the Base64 box to decode back into UTF-8 text.
- 2
Toggle URL-Safe Base64 (RFC 4648 §5)
Enable 'URL-Safe Base64 (- and _)' when encoding tokens for query parameters, filenames, or JSON Web Tokens (JWTs).
- 3
Toggle Padding (=) or Data URI Prefix
Optionally omit trailing `=` padding characters for compact tokens, or view the `data:text/plain;base64,...` Data URI snippet.
- 4
Inspect Byte Size & Expansion Ratio
Monitor the telemetry bar to see the UTF-8 input byte length, Base64 output length, and the ~33% encoding overhead.
- 5
Copy or Download Result
Click Copy on either panel or download the encoded/decoded output as a `.txt` file.
Key Features of Our Base64 Encode & Decode
100% UTF-8 & Emoji Safe (No Latin1 Crash)
Uses `TextEncoder` and `TextDecoder` byte streams so emojis, smart quotes, and international scripts encode and decode flawlessly.
RFC 4648 URL-Safe Base64 Mode
Translates `+` to `-` and `/` to `_` (and decodes both standard and URL-safe variants automatically).
Padding (=) Stripper & Auto-Repair
Optionally strips `=` padding when encoding, and automatically restores missing `=` padding when decoding unpadded JWT/URL strings.
Bidirectional Live Sync
Edit plain text on the left or Base64 on the right—both panels stay synchronized on every keystroke.
HTTP Basic Auth & Data URI Helpers
Quickly see how `username:password` encodes into an `Authorization: Basic ...` header or a browser Data URL.
MIME 76-Character Line Wrap Option
Optionally wrap long Base64 output at 76 characters per line for RFC 2045 MIME email and PEM certificate compatibility.
Key Benefits & Advantages
Never Hit the 'InvalidCharacterError' btoa Bug
Safely encode JSON payloads containing international user names, currency symbols (`€`, `₹`), and emojis without crashes.
Decode Unpadded URL & JWT Segments Effortlessly
Many OAuth and JWT strings omit trailing `=` signs and use `-`/`_`. Our decoder repairs and translates them automatically.
Keep Credentials & Secrets Off the Cloud
Encode Kubernetes `Secret` manifests, `.env` credentials, and HTTP Basic Auth headers locally in your browser memory.
Understand the 4-for-3 Byte Math
See the exact byte-to-character expansion metrics for capacity planning in database columns and API payloads.
Common Real-World Use Cases
HTTP Basic Authentication Headers
Encode `client_id:client_secret` strings into `Authorization: Basic <base64>` headers for OAuth2 and REST API testing.
Kubernetes Secrets & Cloud Configs
Encode and decode `data:` fields in Kubernetes `Secret` YAML manifests and Terraform `user_data` scripts.
Inline Data URLs for Web & CSS
Encode SVG markup or small configuration payloads into `data:image/svg+xml;base64,...` strings.
Debugging Webhook & Email MIME Payloads
Decode Base64-encoded body fields from Gmail API responses, AWS SNS/SQS messages, or GitHub API file contents.
How Base64 Encode & Decode Works Technically
Base64 (standardized in RFC 4648) maps sequences of three 8-bit octets ($3 \times 8 = 24$ bits) into four 6-bit indices ($4 \times 6 = 24$ bits), where each 6-bit value $v \in [0, 63]$ indexes into the alphabet `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`. When the input byte length $L$ is not a multiple of 3, zero bits are appended to form the next 6-bit boundary, and one (`=`) or two (`==`) pad characters are appended so the output length is always a multiple of 4 (`4 * Math.ceil(L / 3)`).
Because JavaScript strings are UTF-16 code unit sequences while `btoa()` only accepts binary strings where each code unit is $\le \text{0xFF}$ (ISO-8859-1 / Latin1), passing a multi-byte character directly to `btoa()` throws an exception. Our implementation first converts the JavaScript string into a UTF-8 `Uint8Array` via `new TextEncoder().encode(str)`, maps each byte into a Latin1 binary string chunk, and applies `btoa()`. On decode, it normalizes URL-safe characters (`-` $\to$ `+`, `_` $\to$ `/`), restores mod-4 `=` padding, converts the `atob()` binary string back into a `Uint8Array`, and decodes UTF-8 via `new TextDecoder('utf-8', { fatal: true }).decode(bytes)`.
Expert Tips for Best Results
- Base64 is an encoding scheme, NOT encryption! Anyone can decode a Base64 string back to plain text without a key—never rely on Base64 alone to hide passwords in public code.
- Every 3 bytes (24 bits) of input data are split into four 6-bit groups (4 Base64 characters), which is why Base64 always increases data size by approximately 33%.
- Trailing `=` or `==` signs at the end of a Base64 string are padding indicators showing that the final group of bytes had only 2 bytes (`=`) or 1 byte (`==`).
- When passing Base64 strings inside URL query parameters (`?token=...`), always enable 'URL-Safe Base64' so `+` isn't misinterpreted as a space and `/` doesn't break path routing.
- If you are inspecting a 3-part dot-separated token starting with `eyJ...`, try our dedicated JWT Token Decoder for color-coded header, payload, and expiration analysis!
100% Local Browser Privacy Guarantee
All Base64 encoding and decoding runs 100% locally in your browser using the Web TextEncoder API. Credentials, secrets, and tokens never leave your device.
Frequently Asked Questions About Base64 Encode & Decode
Is Base64 a form of encryption?+
No. Base64 is strictly a binary-to-text encoding format (RFC 4648) designed for safe data transport, not security. Anyone can decode Base64 instantaneously without a secret key.
Why does JavaScript's built-in btoa() fail on emojis and accented letters?+
The legacy browser `btoa()` function was designed for 8-bit Latin1 strings (code points 0–255). Emojis and non-ASCII characters have Unicode code points above 255. Our tool encodes text into UTF-8 bytes via `TextEncoder` first, making it 100% safe for any Unicode character.
What is URL-Safe Base64 (base64url)?+
Standard Base64 uses `+`, `/`, and `=`, which have special reserved meanings in URLs (`+` means space in query strings, `/` separates path segments, and `=` separates keys from values). URL-Safe Base64 replaces `+` with `-`, `/` with `_`, and often omits `=` padding.
Why do many Base64 strings of JSON start with 'eyJ'?+
In UTF-8/ASCII, the opening curly brace and quote of a JSON object (`{"`) has the 24-bit binary sequence `01111011 00100010 ...`. The first two 6-bit Base64 chunks (`011110` = 30 and `110010` = 50) map directly to the letters `'e'` and `'y'`, followed by `'J'`!
Why are there '=' or '==' signs at the end of Base64 strings?+
Base64 processes input in 3-byte (24-bit) blocks. If your input length isn't evenly divisible by 3, `=` padding characters are added at the end so the encoded string length is an exact multiple of 4 characters.
How much larger does Base64 make my data?+
Base64 converts every 3 bytes of input into 4 ASCII bytes of output, which increases the payload size by approximately 33.3% (plus 1 or 2 bytes for padding).