What Is Base64?
Base64 is a way of writing any data, such as text, an image or a file, using only 64 safe characters: the letters A to Z and a to z, the numbers 0 to 9, plus "+" and "/". Because the result is plain text, it can travel through systems that were designed for text only, such as email, web forms, JSON and URLs, without being damaged.
How Base64 Encoding Works
Three bytes become four characters
Computers store data as bytes. Base64 takes the bytes three at a time, which is 24 bits, and splits them into four groups of 6 bits. Each 6-bit group is a number from 0 to 63, and each number maps to one character of the Base64 alphabet. For example, the text "Man" becomes TWFu, "Hello" becomes SGVsbG8= and "Lumara" becomes THVtYXJh.
Padding and size
When the data does not divide into groups of three bytes, one or two "=" signs are added at the end so the length is a multiple of four. Because three bytes become four characters, Base64 is about one third larger than the original data, and more if you add line breaks.
How to Use the Base64 Encoder and Decoder
- Choose Encode to turn text into Base64, Decode to turn Base64 back into text, or File to Base64 to convert a file.
- Type or paste your input. With live mode on, the result appears as you type. Turn it off and use the button if you work with very large inputs.
- Set the character set if you need something other than UTF-8.
- Use Treat each line separately to convert a list of values, one per line.
- Press Copy result, or Download result to save it as a .txt file.
Need something to practice with? Generate sample text with the Lorem Ipsum Generator, paste it in, and watch how the output grows.
If you paste Base64 that decodes to a picture or another file instead of text, the decoder detects common types such as PNG, JPEG, GIF, WebP and PDF and offers a download button, with a preview for images.
Choosing the Right Character Set
Base64 works on bytes, not on letters, so text must first be turned into bytes using a character set. The default, UTF-8, can represent every language and emoji and is what most modern systems use. Other options are included for older data: ASCII covers basic English letters, ISO-8859-1 and Windows-1252 cover Western European languages, and UTF-16 is used by some Windows software.
The character set must match on both sides. If you decode with a different set than the one used to encode, accented letters and symbols turn into the wrong characters. Files and images are not text, so they do not use a character set at all.
URL-Safe Base64
The "+" and "/" characters have special meanings in web addresses. A variant called Base64URL, defined in RFC 4648, replaces them with "-" and "_" and usually drops the "=" padding. Switch on URL-safe Base64 when the result will go into a link, a file name or a token. The decoder accepts both forms. For general link encoding, see the URL Encoder/Decoder.
Where Base64 Is Used
- Email attachments: the MIME standard encodes files as Base64 text, usually in lines of 76 characters. That is what the line-splitting option does.
- Data URIs: small images and fonts can be placed directly inside HTML or CSS as
data:image/png;base64,…. - Web tokens: JSON Web Tokens use URL-safe Base64 for their parts. Decode one and format the result with the JSON Formatter & Validator.
- HTTP Basic authentication: the username and password are joined and encoded as Base64 in a header.
- APIs and config files: binary values are stored as text inside JSON, XML and settings files.
Base64 Is Not Encryption
Base64 only changes how data is written. Anyone can decode it, with no key or password, so it does not protect secrets. Basic authentication headers, for example, are only safe when sent over HTTPS. Use real encryption for anything private.
Troubleshooting
- "Invalid character": the text contains something outside the Base64 alphabet. The message shows which character and where, which helps you find stray quotes or punctuation.
- "Length is not valid": part of the data is missing, often from a copy that was cut short.
- Garbled letters: the character set is probably wrong. Try UTF-8, then Windows-1252 or ISO-8859-1.
- "Does not look like text": the data is a file or binary content. Download it with the button that appears.
- Missing "=" at the end: this is fine. The decoder adds padding back.
Planning to share a long link to a demo or test page that shows your result? A short link is easier to send. The free URL shortener from Lumara Links makes one in seconds, but do not shorten links that contain tokens, keys or other secrets.
Worked Examples
- The text
Manencodes toTWFu. Helloencodes toSGVsbG8=. The equals sign is padding.Lumaraencodes toTHVtYXJh, with no padding, because six characters divide evenly into groups of three.- The two bytes
FB FFencode to+/8=in standard Base64 and to-_8in URL-safe Base64. data:text/plain;base64,SGVsbG8=is a data URI. Paste it into the Decode tab and you getHello.
Frequently Asked Questions
What is Base64 used for?
It lets binary or special-character data travel safely as plain text, for example in email, data URIs, web tokens and APIs.
Is Base64 encryption?
No. It is an encoding that anyone can reverse. It offers no security.
Why does Base64 end with an equals sign?
The "=" is padding. It brings the length up to a multiple of four when the data does not divide evenly into three-byte groups.
Why is the Base64 output larger than the input?
Three bytes become four characters, so the output is about 33 percent larger.
Can I decode Base64 into an image or a PDF?
Yes. Paste the Base64, with or without the data URI prefix, into the Decode tab. If it is a recognized file type, a download button appears.
Does it support Arabic, accents and emoji?
Yes, when you use UTF-8, the default character set.
What is the largest file I can convert?
The File to Base64 tab accepts files up to 20 MB.
Is my data uploaded or saved?
The conversion runs in your browser. The tool does not upload or save your text or files. The page also loads a cookie banner and an advertisement from third-party services, described in our Privacy Policy. Do not paste passwords or secrets into any online tool you do not trust.
Related Tools and Guide
- URL Encoder/Decoder Encode or decode URLs and query strings with several encoding types and character sets, and break any link into its parts.
- JSON Formatter & Validator Format, minify, validate and fix JSON with a tree view and clear error messages that show the line and column.
- Image Format Converter Convert images between JPG, PNG and WebP, plus GIF, BMP and AVIF to JPG, PNG or WebP. Private and instant.
- Read the guide: Base64 Encoder/Decoder: What It Is and How to Use It A step-by-step article about this tool.