Base64 Encoder / Decoder
What is Base64 encoding?
Base64 is a binary-to-text encoding scheme that represents binary data using a set of 64 printable ASCII characters (A–Z, a–z, 0–9, +, /). It is used to safely transmit binary data over channels that only support text, such as email, JSON, XML, or HTTP headers.
Important: Base64 is not encryption. It is a fully reversible encoding with no key or secret. Never use it to secure sensitive data.
Common use cases
- Inline images in CSS/HTML —
data:image/png;base64,...embeds images directly without a separate HTTP request. - Email attachments — MIME encoding uses Base64 to attach binary files to text-based emails.
- JWT tokens — The header and payload parts of a JWT are Base64url-encoded JSON objects.
- Binary data in JSON APIs — When you need to send files or images in a JSON body.
- Basic Auth headers — HTTP Basic Authentication encodes
username:passwordin Base64.
Standard Base64 vs URL-safe Base64 (Base64url)
Standard Base64 uses +, /, and = (padding). These characters are reserved in URLs, which causes issues when Base64 strings appear in query parameters, JWT tokens, or filenames.
Base64url solves this by replacing + with - and / with _, and omitting the = padding. It is the variant used in JWT, OAuth 2.0 PKCE, and most modern APIs. Use the toggle above to switch between the two modes.
Size impact
Base64 encoding increases data size by approximately 33%. Every 3 bytes of binary input become 4 ASCII characters. For inline images, this tradeoff is often worth eliminating an HTTP request — but for large assets it is usually better to serve the original file.
Frequently Asked Questions
No. Base64 is a reversible encoding with no key or password. Anyone who has a Base64-encoded string can decode it instantly. Do not use it to protect sensitive data — use proper encryption (AES, RSA) instead.
Base64url replaces the two URL-unsafe characters: + becomes -, and / becomes _. The = padding is also removed. The result can safely appear in URLs, filenames, and HTTP headers. JWTs always use Base64url for their header and payload parts.
Use the drop zone on this page. Drag and drop an image or click to select one — the full Data URL is generated immediately, ready to use in your HTML or CSS. No upload to any server occurs.
Use btoa(str) for plain ASCII strings, or for Unicode: btoa(unescape(encodeURIComponent(str))). For files, use the FileReader API with readAsDataURL(). To decode: atob(base64str).
Use the base64 module: import base64; base64.b64encode(b"Hello"). For URL-safe: base64.urlsafe_b64encode(b"Hello"). To decode: base64.b64decode(encoded).
Base64 encodes 3 bytes at a time into 4 characters. When the input length is not a multiple of 3, padding characters = are added to make the output length a multiple of 4. One = means 1 byte of padding was needed; two == means 2 bytes. Base64url omits this padding entirely.
No. All encoding, decoding, and image processing happens entirely in your browser via JavaScript. Nothing you paste or upload ever leaves your machine.
Other useful developer tools
- JWT Decoder — the header and payload of a JWT are Base64url-encoded
- JSON Formatter & Validator
- Regex Tester
- Unix Timestamp Converter