Base64 Encoder & Decoder
Encode plain text to Base64 or decode Base64 strings back to readable text instantly. Supports standard and URL-safe (RFC 4648) variants. Private, fast, works offline.
Base64 encoding converts binary or text data into ASCII characters using 64 printable symbols. The word "Hello" encodes to SGVsbG8= — Base64 always adds roughly 33% overhead in size. This format is used to embed images in HTML/CSS as data URIs, pass binary data through JSON APIs, and encode email attachments where only ASCII is safely transmittable.
What Is Base64 and When Do You Need It?
1. Embedding Images in CSS and HTML (Data URIs)
One of the most practical uses of Base64 in frontend development is embedding binary assets — icons, small images, fonts — directly inside CSS or HTML files as data URIs. Instead of an HTTP request to fetch an image file, you inline the entire binary content as a Base64-encoded string within a src or url() attribute. This eliminates a network round-trip for small assets and is particularly effective for critical above-the-fold icons or SVG sprites that would otherwise block rendering. The tradeoff is a ~33% size increase due to Base64 overhead, so this technique is best reserved for files under 5–10 KB.
// Encode (UTF-8 safe)btoa(unescape(encodeURIComponent(text)))// Decode (UTF-8 safe)decodeURIComponent(escape(atob(base64)))// URL-safe variant: replace +/ with -_encoded.replace(/\+/g, '-').replace(/\//g, '_')// Size overhead: ceil(n / 3) * 4 bytes (~33% larger) 2. API Authentication Headers (HTTP Basic Auth)
HTTP Basic Authentication requires credentials to be transmitted as a Base64-encoded string in the Authorization header. The format username:password is encoded and prefixed with Basic, producing a header like Authorization: Basic dXNlcjpwYXNz. While Base64 is not encryption — it is trivially reversible — it satisfies the HTTP spec requirement for encoding binary-safe strings inside headers. This tool lets you quickly encode or decode these credentials for testing API endpoints, debugging curl commands, or verifying what credentials a client is actually sending. Always use HTTPS alongside Basic Auth to prevent interception.
3. Email Attachments and MIME Encoding
The MIME standard (RFC 2045) uses Base64 as the canonical encoding for binary email attachments. When you send a PDF or image via email, your mail client encodes the file's raw bytes into a Base64 block inside the message body, wrapped with MIME boundary markers. Email servers are designed to transmit text safely, and Base64 ensures that binary bytes — which may include control characters or null bytes — survive the journey intact. Decoding a MIME attachment manually (for debugging bounced emails, malformed attachments, or email security analysis) is one of the classic reasons developers reach for a Base64 decoder.
4. JWT Token Inspection
JSON Web Tokens (JWTs) consist of three Base64URL-encoded segments separated by dots: the header, the payload, and the signature. The header and payload are plain Base64URL (URL-safe variant with -_ instead of +/), containing JSON with claims like sub, exp, and iss. Developers frequently need to decode the payload to inspect expiry timestamps, user roles, or token issuer without running a full JWT library. Paste any JWT segment into this decoder, and you'll immediately see the underlying JSON — useful for debugging auth flows, checking token freshness, or auditing what data your backend is embedding.
Base64 Format Comparison Table
| Input / Scenario | Result / Example | Notes |
|---|---|---|
| Plain text 'Hello' | SGVsbG8= | Classic encode example |
| Plain text 'Hello World' | SGVsbG8gV29ybGQ= | Space encoded cleanly |
| Size overhead | +~33% bytes | ceil(n/3)*4 formula |
| URL-safe chars | - replaces +, _ replaces / | Safe in URLs & JWT |
| Standard vs URL-safe | abc+/== → abc-_== | RFC 4648 §5 variant |
| UTF-8 emoji encode | 😀 → 4OCRAA== | Multi-byte chars supported |
Frequently Asked Questions
How much does Base64 increase file size?
Base64 encoding typically results in a 33% size overhead compared to plain text or binary.
What is the Base64 value for 'Hello'?
The standard Base64 string for the word 'Hello' is SGVsbG8=.
Can I use this for URL parameters?
Yes, we support URL-safe variants, replacing '+' and '/' with '-' and '_' respectively.
Is it safe to decode my JWT tokens here?
Yes. Since this tool is offline-first, your tokens are decoded locally and never sent over the internet.
How do I convert text for a Data URI?
Paste your text or CSS, encode it, and wrap it in the data:text/plain;base64,... format.
What is the formula for Base64?
Encoding uses btoa(unescape(encodeURIComponent(text))) while decoding uses the inverse decodeURIComponent(escape(atob(str))).