Base64 Encoder & Decoder Online for Text and Files
Encode or decode Base64 in seconds. Supports UTF-8 text, URL-safe Base64 and files, right in your browser.
Choose a binary file to encode, or a Base64 text file to decode
Conversion Settings
Uses CRLF line endings when enabled.
Encode and Decode Base64 Online: Everything You Need to Know
Need to decode a Base64 string or convert readable text into Base64? Use the Base64 Encoder & Decoder above to switch between plain text and Base64, work with Unicode characters, and handle URL-safe encoding. The guide below explains the format, shows correct examples, and helps you understand common decoding errors.
Base64 is useful when an application needs to represent binary data using printable text characters. It appears in web APIs, email attachments, data URLs, and other text-oriented systems. However, Base64 does not encrypt or protect information.
What Is Base64 Encoding?
Base64 encoding is a method of representing bytes using a set of 64 printable characters. It translates binary information into a text form that can be handled by systems designed for text. The format is defined by RFC 4648.
Standard Base64 uses uppercase letters A–Z, lowercase letters a–z, digits 0–9, plus +, and slash /. An equal sign (=) may appear at the end as padding. Because Base64 works with bytes rather than characters, the original text should first be converted into bytes using a character encoding such as UTF-8.
Base64 encoding
Converts original bytes into Base64 characters that can be copied, stored, or transmitted as text.
Hello → SGVsbG8=Base64 decoding
Converts the Base64 representation back into the original bytes, which can then be interpreted as text or saved as a file.
SGVsbG8= → HelloHow to Encode and Decode Base64 Online
Encode text to Base64
Select Encode in the converter above.
Paste or type the text you want to convert. For example, Hello World.
Run the conversion and check the Base64 output.
Copy the encoded string or save it using the tool’s available download option.
Decode Base64 to text
Select Decode in the converter above.
Paste a Base64 value, such as SGVsbG8gV29ybGQ=.
Run the decoder to recover the original bytes.
Read the decoded UTF-8 text or download the bytes if the value represents a file.
Use the Swap action when you want to reverse a conversion. If you are working with a URL token or JWT segment, choose URL-safe Base64 rather than assuming standard Base64 is always appropriate.
Base64 Encoding and Decoding Examples
These examples use UTF-8 for the original text. Notice that encoded output does not resemble the input, even though the conversion is reversible.
| Original text | Base64 value | What it illustrates |
|---|---|---|
Hi | SGk= | Two-byte ASCII input |
Hello | SGVsbG8= | Ordinary text conversion |
Hello World | SGVsbG8gV29ybGQ= | Text containing a space |
Man | TWFu | Three bytes require no padding |
✓ | 4pyT | UTF-8 Unicode character |
😀 | 8J+YgA== | Multibyte emoji |
Why does Base64 end in = or ==?
Base64 processes input bytes in groups of three and emits characters in groups of four. If the final input group contains only one or two bytes, standard Base64 pads the output with == or = to complete the final group. The padding does not add original data.
How Base64 converts bytes into characters
Three 8-bit bytes make 24 bits. Base64 splits those bits into four 6-bit values and maps them to characters in its alphabet.
For example, Man becomes TWFu. Standard Base64 output is approximately 33% larger than the original byte sequence before optional line breaks or other overhead. More precisely, for n input bytes, padded output contains 4 × ceil(n / 3) characters.
Base64 vs Base64URL: What’s the Difference?
Base64URL is a variation of Base64 designed for URLs and filenames. It uses the same underlying byte-to-text conversion but substitutes two alphabet characters. The difference is especially useful when encoded values appear in web addresses or JWT segments.
| Feature | Standard Base64 | Base64URL |
|---|---|---|
| Character 62 | + | - |
| Character 63 | / | _ |
| Padding | Usually = when needed | May be omitted by the containing format |
| Typical use | General text and binary encoding | URLs, filenames, JWT segments |
UTF-8 Base64 encoding and international text
Text is made of characters; Base64 encodes bytes. With UTF-8 encoding, the same tool can work with English, Urdu, Arabic, Hindi, Japanese, and emojis. For example, the emoji 😀 uses four UTF-8 bytes before Base64 conversion.
In JavaScript, calling btoa() directly on arbitrary Unicode text may throw an error because it expects a byte-oriented string. A robust implementation first converts Unicode text with TextEncoder, then applies Base64 to the resulting bytes. The reverse operation uses TextDecoder for readable UTF-8 text. See MDN’s btoa() documentation.
How to Convert Files to and from Base64
Base64 can represent images, PDFs, text documents, and other files because it operates on bytes. When you encode a file, the result is a Base64 string. When you decode that string, you recover bytes that should be saved in the appropriate file format.
Text files
Encode a local .txt file, copy its Base64 value, or decode the value back into readable text.
Images
An image’s bytes can be encoded into Base64. A data URL also includes a media type such as image/png.
PDF and binary files
Decoded bytes may not be readable as text. Download them as a binary file rather than interpreting them as UTF-8.
Can Base64 store an image directly in HTML?
Yes. A data URL can embed a small Base64-encoded image using a structure such as data:image/png;base64,.... The prefix identifies the media type and encoding, while the remainder carries the image data. It can be convenient for small embedded assets, but large inline images increase document size and may reduce caching flexibility.
For ordinary text encoding, choose the text mode. For file conversion, use the file controls in the tool above when available and respect the interface’s file-size limit. Do not assume that every Base64 value represents UTF-8 text.
Common Base64 Decode Errors and How to Fix Them
If your Base64 string does not decode, check its alphabet, padding, input length, and whether the decoded bytes are actually text.
| Problem | Likely cause | What to try |
|---|---|---|
| Invalid character error | The string contains characters outside the selected Base64 alphabet | Check for typos, punctuation, or use of standard vs URL-safe characters |
| Incorrect padding | = is misplaced or the selected format expects different padding | Use the correct padded or permitted unpadded mode |
| Impossible input length | The unpadded character count is one more than a multiple of four | Look for missing or extra characters |
| Unreadable decoded text | Decoded bytes are binary or do not form valid UTF-8 text | Download the original bytes or identify the correct character encoding |
| Spaces replace plus signs | A Base64 string was passed through a URL/form decoder | Restore the value or use Base64URL when the receiving format permits it |
| Unexpected prefix | Input contains data:...;base64, | Use a data-URL-aware decoder or extract the Base64 portion |
Where Is Base64 Encoding Used?
Web APIs and JSON
Base64 can carry bytes inside JSON string fields when an API contract requires it. JSON itself does not require Base64 for ordinary text.
Email attachments
MIME email can use Base64 to represent attachment bytes. MIME-specific line wrapping is different from RFC 4648’s default no-wrap rule.
Data URLs
Browsers can display certain resources from data: URLs that embed Base64 content, such as small images.
JWT tokens
JWT header and payload segments typically use Base64URL. Decoding them lets you read the bytes but does not verify the token’s signature or trustworthiness.
Is Base64 safe for sensitive data?
Base64 does not provide confidentiality. A Base64-encoded password, API token, or private document is still sensitive and can be readily decoded. Use HTTPS in transit, suitable encryption when confidentiality is required, and proper secret storage. Encoding alone is not a security measure.
Base64 Encoder & Decoder FAQs
What is the difference between Base64 encode and decode?
How can I decode Base64 to plain text online?
Is Base64 encoding the same as encryption?
Why does Base64 sometimes end with one or two equal signs?
Does Base64 support emoji, Urdu, and other Unicode text?
Can I decode Base64 without uploading it to a server?
What is Base64URL used for?
Why is my Base64 string invalid?
Does Base64 increase file size?
Can Base64 decoding verify a JWT signature?
Technical reference: RFC 4648, Base-N Encodings; MDN, Window.btoa().
