Base64 Encoder & Decoder
Encode UTF-8 text or files into Base64, or decode Base64 back into readable text or binary data. Switch to Base64URL for URL-safe output.
What is Base64?
Base64 is a binary-to-text encoding scheme that represents bytes using a set of printable ASCII characters. Standard Base64 uses uppercase letters (A–Z), lowercase letters (a–z), digits (0–9), plus (+), and slash (/). The equals sign (=) may appear at the end as padding.
Base64 is useful when binary data or text bytes need to be represented inside text-based formats and protocols. It is commonly seen in email MIME content, API payloads, JSON or XML fields, data URIs, authentication headers, and other places where a text representation of bytes is convenient.
Base64 is encoding, not encryption. It does not use a secret key and does not provide confidentiality. Anyone with the encoded value can decode it back to the original bytes.
How to encode text to Base64
Encoding converts UTF-8 text or file bytes into a Base64 string.
- Enter text or choose a file Type or paste UTF-8 text into the input area, or switch to file mode if file encoding is supported.
- Choose the Base64 format Select Standard Base64 for general use or Base64URL when you need URL- and filename-safe output.
-
Choose optional output settings
If Data URI output is supported, enable it when you need a value such as
data:image/png;base64,...for a supported file type. - Copy or download the result Copy the encoded text to your clipboard or download it if the tool provides a download option.
How to decode Base64
Decoding reverses the process and restores the original bytes from a Base64 string.
- Paste the Base64 value Paste Standard Base64, Base64URL, or a supported Base64 Data URI into the input area.
- Select the input format Choose Standard Base64 or Base64URL, or use automatic detection when the input format can be identified reliably.
- Review the decoded result If the decoded bytes represent UTF-8 text, the readable value can be shown directly. Binary data should be handled as bytes rather than forced into a text view.
- Copy text or download binary data Copy readable decoded text or download the decoded bytes if binary download is supported.
Why UTF-8 handling matters
Base64 works with bytes rather than abstract characters. Plain English ASCII text maps cleanly to single-byte values, but modern text may contain accented letters, currency symbols, non-Latin scripts, and emoji that require multiple UTF-8 bytes.
For example, characters such as é, ₹, 你好, or 😀 should first be converted into UTF-8 bytes before Base64 encoding.
When implemented with browser APIs such as TextEncoder and TextDecoder, UTF-8 text can be encoded and decoded without treating Unicode characters as single-byte ASCII values.
Standard Base64 vs Base64URL
Standard Base64 uses + and / as part of its alphabet. Those characters can be inconvenient in URLs and filenames, so RFC 4648 defines a URL- and filename-safe variant called Base64URL.
| Feature | Standard Base64 | Base64URL |
|---|---|---|
| Plus character | Uses + |
Uses - |
| Slash character | Uses / |
Uses _ |
| Padding | = padding is commonly included |
Padding may be omitted when the surrounding specification allows it |
| Common use | Email, text payloads, APIs, data fields | URLs, filenames, JWT segments |
Base64URL is still Base64 encoding. It changes the alphabet so the result is easier to use in URL- and filename-oriented contexts.
What does Base64 padding mean?
Base64 processes input bytes in groups of three. Three bytes contain 24 bits, which are divided into four 6-bit values. Each 6-bit value selects one character from the 64-character Base64 alphabet.
This is why three input bytes normally produce four Base64 characters and why Base64 output is typically about one-third larger than the original byte data before other transport overhead.
If the final group contains fewer than three bytes, padding may be used:
- 1 input byte: Produces two Base64 characters followed by
==. Example:M → TQ==. - 2 input bytes: Produces three Base64 characters followed by
=. Example:Ma → TWE=. - 3 input bytes: Produces four Base64 characters with no padding. Example:
Man → TWFu.
Base64 encoding and decoding examples
These examples show how UTF-8 text can appear in Standard Base64 and Base64URL:
| Input | UTF-8 size | Standard Base64 | Base64URL |
|---|---|---|---|
Hello |
5 bytes | SGVsbG8= |
SGVsbG8 |
Hello? |
6 bytes | SGVsbG8/ |
SGVsbG8_ |
Hello 👋 |
10 bytes | SGVsbG8g8J+Riw== |
SGVsbG8g8J-Riw |
{"name":"Asha"} |
15 bytes | eyJuYW1lIjoiQXNoYSJ9 |
eyJuYW1lIjoiQXNoYSJ9 |
When Base64 is useful
Practical developer use cases include:
- API payloads: Represent byte data inside JSON, XML, or other text-based formats when the receiving system expects Base64.
- HTTP Basic Authentication: Basic Authentication represents the
username:passwordbyte sequence using Base64. Base64 itself does not protect the credentials, so the connection should still use HTTPS. - Log inspection: Decode Base64 values found in application logs, diagnostics, or error payloads.
- Base64URL values: Prepare URL-safe encoded data for protocols or formats that require the Base64URL alphabet.
- JWT inspection: JWT header and payload segments use Base64URL encoding. Decoding a segment can make its JSON readable, but decoding does not verify the token signature.
- Data URIs: Represent small binary assets as Base64 inside supported
data:URLs. - Email and MIME: Represent binary attachments or non-text bytes in formats that use Base64 transfer encoding.
Common Base64 mistakes
- Treating Base64 as encryption: Base64 is reversible encoding and does not protect confidential information.
- Using
btoa()directly with arbitrary Unicode text: Browserbtoa()expects each input string code unit to fit within a single byte. Unicode text should first be converted to bytes, typically using UTF-8. - Mixing Base64 and Base64URL: Standard Base64 uses
+and/, while Base64URL uses-and_. Use the variant expected by the receiving system. - Removing padding without checking the format: Some Base64URL contexts allow omitted padding, while other systems expect the traditional padded form.
- Assuming decoded data is always text: Base64 can represent images, PDFs, archives, audio, encrypted data, or any other byte sequence.
- Passing a complete Data URI to a raw Base64 decoder: A prefix such as
data:image/png;base64,describes the data. The Base64 payload begins after the comma.
Browser-based processing and privacy
Base64 encoding and decoding run locally in your browser to preserve privacy. TryFormatter does not need to upload entered text to its server to perform the conversion.
If file mode is implemented entirely client-side, files can also be read and converted in browser memory without requiring a server-side conversion step.
Frequently Asked Questions
What is Base64 encoding?
Base64 is a binary-to-text encoding scheme that represents byte data using printable characters such as A–Z, a–z, 0–9, +, and /.
Is Base64 a form of encryption?
No. Base64 is reversible encoding and provides no confidentiality. Anyone with the encoded value can decode it without a secret key.
Why does Base64 sometimes end with = or ==?
The equals sign is padding used when the number of input bytes does not divide evenly into groups of three. One or two padding characters may appear at the end of Standard Base64 output.
What is Base64URL and when should I use it?
Base64URL is a URL- and filename-safe Base64 variant. It replaces + with - and / with _. Padding may also be omitted when the surrounding format allows it.
Can this tool encode Unicode characters and emojis?
Yes, when text is converted into UTF-8 bytes before Base64 encoding. This allows accented letters, non-Latin scripts, currency symbols, and emoji to round-trip correctly.
Why does decoded Base64 sometimes look unreadable?
The original Base64 value may represent binary data rather than UTF-8 text. Images, PDFs, archives, audio, and other files can all be represented with Base64.
Does TryFormatter upload my text or files to a server?
No server upload is required for the Base64 text conversion. If file mode is implemented client-side, file encoding and decoding can also run in the browser without a server-side conversion step.