What is Base64 and why is it used?
Base64 is an encoding scheme that converts binary data into a string of ASCII characters. The name comes from the fact that it uses 64 different characters — the letters A–Z (both upper and lowercase), the digits 0–9, and the symbols + and / — to represent binary data. Each Base64 character represents exactly 6 bits of data, which means every 3 bytes of binary data becomes 4 Base64 characters.
The main reason Base64 exists is to allow binary data — like images, files, and arbitrary byte sequences — to be safely transmitted or stored in systems that only handle text. Email (via the MIME standard), HTML, JSON APIs, and authentication tokens all commonly use Base64 because they're text-based protocols that can't directly carry raw binary data without it getting corrupted.
The four modes in this tool
Text encode and decode
The standard use case. Type or paste any text and click "Encode to Base64" to get the Base64 representation. Paste a Base64 string and click "Decode Base64" to get the original text back. The tool handles Unicode text properly — including emoji, Chinese characters, Arabic, and any other script — by encoding to UTF-8 first before Base64 encoding.
The URL-safe option replaces + with - and / with _ in the output. This is the variant used by JWTs (JSON Web Tokens), OAuth tokens, and many web APIs where standard Base64 characters could be misinterpreted as URL syntax. The line wrapping option adds line breaks every 76 characters, which is the standard for MIME-encoded email attachments and PEM certificate files.
Image to Base64
Upload any image file — PNG, JPG, SVG, GIF, WebP — and the tool converts it to a Base64 data URI. The output format is data:image/png;base64,iVBORw0KGgo..., which can be pasted directly into HTML or CSS as an <img src="..."> attribute or a background-image: url(...) value.
This is one of the most common uses of Base64 for frontend developers — embedding small icons, logos, and UI images directly in HTML or CSS eliminates a separate HTTP request, which can improve page load performance for small images. It's also used for generating email-safe inline images, since many email clients block external image URLs.
Base64 to Image
Paste a Base64 image string and see it rendered as a real image in the preview panel. This is useful when debugging API responses that return Base64-encoded images, verifying that an image encoded to Base64 is correct before embedding it, or simply understanding what a Base64 string represents. The tool accepts both the full data URI format (data:image/...;base64,) and raw Base64 without the prefix.
File to Base64
Encode any file — not just images — to Base64. PDFs, ZIP archives, Word documents, audio files, and any other binary format can be dragged in and encoded. This is used in email attachments (MIME encoding), embedding files in JSON payloads, transmitting files through APIs that only accept text, and storing binary files in text-based databases or configuration files.
Common uses of Base64
HTML and CSS inline images
Instead of linking to an external image file, you can embed the image directly in HTML or CSS using a Base64 data URI. For small images like icons, buttons, and logos — especially ones used repeatedly across a page — this can eliminate HTTP requests and improve loading speed. The trade-off is that Base64 increases file size by about 33%, so it's most beneficial for small images under about 5KB.
JSON API payloads
REST APIs that transfer files — profile pictures, uploaded documents, generated PDFs — often Base64-encode the file content and include it as a string in the JSON response. When you receive a Base64-encoded image from an API and need to verify it renders correctly, the Base64 → Image mode in this tool lets you paste the string and see it immediately.
Authentication and JWTs
JSON Web Tokens (JWTs) use URL-safe Base64 encoding to represent their header and payload sections. The three parts of a JWT are Base64url-encoded strings separated by dots. Decoding the first or second part of a JWT reveals the algorithm and claims in plain JSON — a common debugging technique.
Email attachments
The MIME standard (used for email) specifies Base64 as one of the content transfer encoding methods for attachments. When you receive an email with an attachment, your email client is typically Base64-decoding the attachment behind the scenes. The line wrapping option in this tool's text mode produces output formatted to the MIME standard (76 characters per line).
Frequently asked questions
No. Base64 is encoding, not encryption. It's a reversible, publicly known transformation that doesn't require a key to decode. Anyone who has a Base64 string can decode it instantly. Base64 is used to make binary data text-safe, not to keep it secret. If you need to secure data, you need actual encryption (AES, RSA, etc.) — not Base64.
Base64 encodes data in groups of 3 bytes into 4 characters. If the input isn't a multiple of 3 bytes, padding characters (=) are added at the end to make the output length a multiple of 4. One = means one byte of padding was needed; == means two bytes of padding were needed. This padding is part of the standard and is expected by Base64 decoders.
Standard Base64 uses + and / as two of its 64 characters. These characters have special meaning in URLs — + means a space, and / is a path separator. URL-safe Base64 replaces + with - and / with _ so the encoded string can be used in URLs and query parameters without encoding. This variant is used by JWTs, OAuth tokens, and many web APIs.
Base64 increases size by approximately 33%. Every 3 bytes of input becomes 4 Base64 characters. So a 100KB image becomes about 133KB when Base64-encoded. This size increase is shown in the stats bar after encoding. For this reason, Base64 embedding of large files is generally not recommended — the HTTP overhead savings from eliminating a request are usually outweighed by the size increase.
No. All encoding, decoding, and file processing happens in your browser using JavaScript and the FileReader API. Nothing you encode or decode is sent to any server. You can safely encode sensitive text, private images, and confidential files.