How to use the Base64 Encoder / Decoder tool
- Choose a modeUse “Text” to encode or decode strings, or “File to Base64” to convert a file into a data URI.
- Enter your dataPaste or type text, or drop a file onto the box.
- Encode or decodeClick the button you need. Tick “URL-safe” if the result will be used in a URL or file name.
- Copy the resultCopy the output, or swap it back into the input to reverse the operation.
Features
- UTF-8 awareEmojis, accented letters and non-Latin scripts encode and decode correctly.
- URL-safe variantUses - and _ instead of + and / and drops padding, as required by JWTs and many APIs.
- Files to data URIsEmbed small images, icons and fonts directly in HTML, CSS or JSON.
- Helpful errorsInvalid characters and binary data are detected and explained.
- PrivateTokens and secrets never leave your browser.
What is Base64?
Base64 is a way of representing binary data using only 64 printable characters: A–Z, a–z, 0–9, plus + and /, with = used for padding. It was designed so that any data, including images and other binary files, can travel safely through systems that only handle text, such as email, JSON, XML and URLs.
Base64 is an encoding, not encryption. Anyone can decode it, so it must never be used to protect passwords or secrets.
How Base64 works
The encoder takes the input three bytes (24 bits) at a time and splits them into four groups of 6 bits. Each 6-bit value (0–63) is mapped to one of the 64 characters. Because 3 bytes become 4 characters, Base64 output is about 33% larger than the original. When the input length is not a multiple of three, one or two = characters are added as padding.
Example: the text Hi! is the bytes 72, 105, 33, which encode to SGkh.
Common uses
- Data URIs: embedding small images or fonts directly in HTML or CSS, such as
data:image/png;base64,iVBOR…, which saves an extra network request. - APIs and JSON: sending file contents or binary data inside JSON payloads.
- Email attachments: MIME encodes attachments in Base64.
- Authentication headers: HTTP Basic Auth sends
username:passwordBase64-encoded, which is why it must only be used over HTTPS. - JSON Web Tokens (JWT): the header and payload are Base64URL-encoded.
Standard vs URL-safe Base64
The + and / characters have special meanings in URLs and file paths, and = is used in query strings. The URL-safe variant (Base64URL) replaces + with - and / with _, and usually omits the padding. The decoder on this page accepts both variants automatically.
When not to use data URIs
Inlining images as Base64 is handy for tiny icons, but for larger images it makes HTML and CSS files bigger, prevents the browser from caching the image separately and can slow down page rendering. As a rule of thumb, keep data URIs for images under a few kilobytes.