Base64 Encode / Decode Converter
Instantly convert text to base64 and base64 to text and back. This online Base64 encoder and decoder handles the full UTF-8 range, so emoji and non-Latin characters are encoded correctly — all computed locally in your browser, with nothing uploaded. Use it for data URIs, API tokens, and safe URL passing.
How To Use
- Paste or type any text into the input box.
- Click Encode to Base64 to convert text to Base64.
- Paste Base64 and click Decode from Base64 to get the text back.
- Use Copy output to copy the result.
Usage Example
Text:
Hello, developers!
Base64:
SGVsbG8sIGRldmVsb3BlcnMh
Unicode works too: Dev 😀 encodes correctly.
Use Cases
Base64 encoding is a day-to-day utility for web developers and DevOps engineers. Embed small images or fonts directly into CSS or HTML as data URIs so the page loads them without extra requests. Inspect or craft the payload segment of a JWT. Pass opaque values such as API keys or hashes through query strings without worrying about percent-encoding. Decode Base64 email bodies, configuration snippets, or credentials shared in tickets. (Percent-encoding values for a URL is a different job — for that, use the URL Encode / Decode tool.) Because everything runs locally, it is also a safe way to peek at any Base64 blob without pasting it into a third-party site.
Best Practices
- Remember that Base64 is not encryption — anyone can decode it. Never put passwords or secrets in Base64 alone.
-
When building a data URI, prefix the output with
data:text/plain;base64,(or the matching MIME type) so browsers render it correctly. - Base64 adds roughly 33% to the original size. For large payloads, prefer dedicated binary formats or compression.
-
Prefer the URL-safe
base64urlvariant (using-and_) when embedding in URLs and JWTs to avoid+,/, and padding issues.
Base64 vs Base64url (RFC 4648 §5)
Standard Base64 ends its output with = padding and uses
+ and / in its alphabet — two characters that
are meaningful inside URLs. Base64url swaps them for - and
_ and drops the padding entirely, producing a string that
can live in a path segment, a query value, or a cookie without
percent-encoding. This is why every JWT uses Base64url for its three
dot-separated segments: paste a JWT's header or payload segment into
this decoder and it resolves directly (for the full claims view, use the
JWT Decoder). When you need to send an
arbitrary string through a URL instead of embedding binary data, that
is a different encoding — use the
URL Encode / Decode tool.
| Base64 (RFC 4648 §4) | Base64url (RFC 4648 §5) | |
|---|---|---|
| Alphabet | A–Z a–z 0–9 + / | same, but - _ instead of + / |
| Padding | = to a multiple of 4 | usually omitted |
| URL-safe | no — + becomes a space in form decoding | yes |
| Typical use | email (MIME), data URIs, certificates | JWT segments, URL tokens, cookie values |
Padding Rules and the "Incorrect padding" Error
The number of trailing = signs is not arbitrary: it is the
smallest value that makes the encoded length a multiple of 4, decided
by the original byte length — 0, 1, or 2. When Python complains with
binascii.Error: Incorrect padding, the string you gave it
is not a multiple of 4 characters long, which almost always means it
was truncated while copying or stripped of its padding in transit. Fix
it by re-copying the complete string; add = to the next
multiple of 4 only as a last resort. The decoder on this page accepts
input with missing padding and completes it automatically — paste and
decode without pre-cleaning.
Base64, UTF-8, and Emoji
Base64 operates on bytes, not characters, so every non-ASCII string is
first serialized to UTF-8 — Dev 😀 becomes the 8-byte
sequence 44 65 76 20 F0 9F 98 80 before encoding. This is
why JavaScript's classic btoa() throws
InvalidCharacterError on emoji: it only accepts one byte
per character. The correct pattern is
btoa(String.fromCharCode(...new TextEncoder().encode(text)))
or, for decoding, new TextDecoder().decode(bytes). This
tool does the UTF-8 conversion for you in both directions, so emoji and
CJK text encode and round-trip correctly.
Frequently Asked Questions
What is Base64 used for?
Base64 encodes binary or text data into a safe ASCII format, commonly used for data URIs, email attachments, JWT segments, and passing data in URLs.
Does it support emoji and non-English text?
Yes. The tool converts to and from UTF-8 first, so Unicode characters are handled correctly.
Is my data uploaded?
No. Encode and decode happen locally in your browser using native functions. Nothing leaves your device.
When should I use Base64 encoding?
Use it whenever you need to move binary or text data through a channel that only accepts safe ASCII characters: embedding images as data URIs, storing tokens in a URL, or preparing content for email systems that cannot carry raw bytes.
Is Base64 the same as encryption?
No. Base64 is an encoding, not encryption. It only changes how bytes are represented so they are safe to transmit; anyone can decode it. Use it for convenience, never for protecting secrets.
Can I encode files or images too?
This tool works on text, but the same algorithm underlies image and file encoding. You can paste a Base64 image string here to verify it, or use it as a quick data-URI helper.
Does it handle line breaks and whitespace?
When decoding, the tool strips harmless whitespace such as newlines because many systems wrap long Base64 output. Encoding produces a single continuous string.
Why do I get "Incorrect padding" and how do I fix it?
Padding is the trailing = signs that make the encoded length a multiple of 4. Its count is fixed by math: the original byte length mod 3 decides whether 0, 1, or 2 = signs are appended. Python raises binascii.Error: Incorrect padding when the string is missing those signs — usually because it was truncated when copied, pasted through a channel that stripped them, or wrapped across lines. This decoder accepts the missing padding and completes it for you, so a truncated-tail-free string decodes without manual fixing. If the error persists, the input is genuinely damaged (characters were lost mid-string), and no amount of padding fixes that.
What is Base64url and when should I use it?
Base64url (RFC 4648 §5) replaces the + and / characters with - and _ and drops the = padding, so the output is safe to use inside URLs, path segments, and cookie values without extra escaping. Tick the Base64url checkbox to produce it; the decoder accepts either alphabet, with or without padding. The three segments of a JWT (header.payload.signature) are Base64url — decode one with the toggle off and it still works.
Why does Base64 break on emoji and how is UTF-8 handled?
Classic btoa/atob in JavaScript only understand single bytes, so passing an emoji through them throws — emoji are 4-byte UTF-8 sequences. This tool converts to and from UTF-8 explicitly before encoding, which is what TextEncoder and TextDecoder do, so multi-byte characters round-trip correctly. If you are debugging JavaScript code, replace atob/btoa with TextDecoder-first helpers or decode the Base64 to bytes and then new TextDecoder().decode(bytes).