How to use the Base64 Encoder / Decoder tool
- Select a modePick “Text” to encode or decode strings, or “File to Base64” to make a data URI from a file.
- Provide the inputType or paste text, or drag a file onto the box.
- Encode or decodePress the relevant button, and tick “URL-safe” if the output will go into a URL or file name.
- Copy the outputCopy the result, or swap it into the input to reverse the conversion.
Base64 tool features
- Unicode handledEmoji, accented characters and non-Latin scripts convert correctly in both directions.
- Base64URL modeSwaps + and / for - and _ and drops the padding, as JWTs and many APIs expect.
- File to data URIEmbed small images, icons and fonts directly in HTML, CSS or JSON.
- Clear error messagesInvalid characters and binary content are detected and explained.
- PrivateTokens and secrets stay inside your browser.
What is Base64 encoding?
Base64 represents binary data using just 64 printable characters, A–Z, a–z, 0–9, + and /, with = as padding. It exists so that any data, images and other binary files included, can pass safely through systems built for text, like email, JSON, XML and URLs.
Remember that Base64 is encoding, not encryption. Anyone can reverse it, so it should never be relied on to protect passwords or secrets.
How Base64 encoding works
The encoder reads the input three bytes (24 bits) at a time and divides them into four 6-bit chunks. Each chunk, a value from 0 to 63, maps to one of the 64 characters. Since every 3 bytes become 4 characters, encoded output is roughly 33% bigger than the source. When the input length isn’t divisible by three, one or two = signs pad the end.
For example, the text Cat is the bytes 67, 97, 116, which encode to Q2F0.
Where Base64 is used
- Data URIs: small images or fonts embedded straight into HTML or CSS, as in
data:image/png;base64,iVBOR…, saving a network request. - APIs and JSON: carrying file contents or binary data inside JSON payloads.
- Email: MIME encodes attachments with Base64.
- HTTP Basic Auth: sends
username:passwordBase64-encoded, which is why it must only travel over HTTPS. - JSON Web Tokens: the header and payload are Base64URL-encoded; inspect them with our JWT Decoder.
Standard Base64 vs URL-safe Base64
In URLs and file paths, + and / carry special meanings, and = appears in query strings. The URL-safe variant, Base64URL, replaces + with - and / with _, and typically leaves out the padding. The decoder here recognises both forms automatically.
When to avoid Base64 data URIs
Inlining images is convenient for tiny icons, but bigger pictures bloat your HTML and CSS, stop the browser caching the image separately and can slow page rendering. A good rule is to inline only images of a few kilobytes or less. For pictures specifically, the Image to Base64 tool adds ready-made HTML and CSS snippets.