About the Base64 Encoder
Base64 turns any data, whether text, an image or a PDF, into a string of plain letters, digits and a few symbols. That makes it safe to put binary data where only text is allowed: inside JSON, an email, an HTML or CSS file, a URL or an HTTP header.
Type text and the Base64 Encoder converts it as you type. The text is first turned into UTF-8 bytes, so accented letters, other alphabets and emoji all encode correctly. Switch to File to encode an image, a font or any other file up to 10 MB, and optionally get a ready-to-use data URL.
Options cover the common variants: URL-safe Base64 with - and _, output without = padding, and line breaks every 76 characters for email. Everything is encoded in your browser, so your text and files never leave your device.
How to use it
- Choose Text or FileText encodes what you type. File encodes the exact bytes of a file you choose or drop.
- Add your inputType or paste text, or drop a file on the drop zone. Dropping a file onto the text box switches to File mode automatically.
- Pick a variantTurn on URL-safe for links and tokens, No = padding if the receiving system expects it, or line breaks for email.
- Get a data URLIn File mode, turn on "Output as a data URL" to get data:type;base64,... for use in HTML or CSS.
- Copy or downloadThe status line shows the input size and the output length. Copy the Base64 or download it as a text file.
Key features
UTF-8 text
Text is encoded as UTF-8, the standard on the web, so "Grüße", "München" and 👋 come out the same as in any other modern tool.
Any file
Images, PDFs, fonts, archives or any other file up to 10 MB, byte for byte.
URL-safe variant
Replaces + with - and / with _ so the result can go into a URL or a file name without escaping.
Padding and line breaks
Remove the trailing = signs, or wrap lines at 76 characters as MIME email requires.
Data URLs
Get a complete data URL with the file's type, ready to paste into an img tag or a CSS background.
Private by design
Nothing is uploaded. Encoding happens on your device, even for files.
Examples
Encoding text
| Text | Bytes | Base64 |
|---|---|---|
| Hello | 5 | SGVsbG8= |
| Hello, world! | 13 | SGVsbG8sIHdvcmxkIQ== |
| café | 5 | Y2Fmw6k= |
| 👋 | 4 | 8J+Riw== |
"café" has four letters but five bytes, because é takes two bytes in UTF-8. The Sample button encodes "Hello, world! Grüße aus München 👋": 39 bytes in, 52 characters out.
Why some results end in =
Base64 turns every 3 bytes into 4 characters. When the input does not divide evenly by 3, = signs fill up the last group:
| Text | Base64 | Padding |
|---|---|---|
| M | TQ== | 2 = signs |
| Ma | TWE= | 1 = sign |
| Man | TWFu | none |
URL-safe Base64
Standard Base64 of <<???>> is PDw/Pz8+Pg==. The / and + would need escaping in a URL. With URL-safe and No = padding turned on, you get PDw_Pz8-Pg, the form used in JSON Web Tokens and many web APIs.
An HTTP Basic authentication header
Basic authentication sends the user name and password as Base64. Encoding user:pass gives dXNlcjpwYXNz, so the header is:
Authorization: Basic dXNlcjpwYXNz
Anyone who sees the header can decode it, which is why Basic authentication should only be used over HTTPS.
A small image as a data URL
Encoding a 62-byte SVG file gives 84 characters of Base64. With "Output as a data URL" on, the result starts with data:image/svg+xml;base64, and is 110 characters long. You can use it directly in CSS:
background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0i..."); Tips
- Expect Base64 to be about a third larger than the original. A 30 KB image becomes about 40 KB of text, so data URLs only pay off for small icons and images.
- Use URL-safe Base64 whenever the result goes into a link, a query string, a cookie or a file name. Standard + and / characters can be changed or misread there.
- If another system rejects your Base64, check whether it expects padding. JSON Web Tokens leave out the = signs; most other formats keep them.
- Turn on line breaks only for email attachments and other MIME content, which allow at most 76 characters per line. JSON, HTML and APIs expect the Base64 on one line.
- To check your result, paste it into the Base64 Decoder. It should give back exactly the text or file you started with.
Common mistakes and limits
- Treating Base64 as encryptionBase64 hides nothing. Anyone can decode it in a second. Never use it to protect passwords, keys or personal data.
- Mixing up character encodingsThis tool encodes text as UTF-8. Some older systems expect Latin-1 or UTF-16, and the same text then gives different Base64, especially for accented letters.
- Expecting data URL options to applyData URLs always use standard Base64 with padding and no line breaks, so the URL-safe, padding and line break options are ignored in that mode.
- Encoding very large files as data URLsBig data URLs make HTML and CSS files heavy and cannot be cached separately. Link to the file instead when it is more than a few kilobytes.
- Copying invisible line breaksWith line breaks turned on, the output contains new lines. Many APIs and JSON parsers reject Base64 with line breaks in it.