🔐 Base64 Encode / Decode
Base64 Encode Decode
Base64 turns any text into a safe ASCII string for embedding in URLs, JSON, emails and data URIs. Pick Encode to convert your text, or Decode to turn a Base64 string back into readable text.
Everything runs locally in your browser with proper Unicode handling, so accented characters and emoji survive the round trip — and your text never leaves your device.
What Base64 is — and what it is not
Base64 is a way of writing binary data using only 64 safe, printable characters: the letters A–Z and a–z, the digits 0–9, and the two symbols + and /, with = used as padding at the end. It exists because many systems that move text around — email, URLs, JSON, HTML, configuration files — were built for plain text and will corrupt or reject raw binary data. By re-expressing any bytes as a string of harmless characters, Base64 lets an image ride inside an email, a token travel inside a JSON document, or a file sit inside a web page as a data URI.
Two misunderstandings are worth clearing up immediately. First, Base64 is not encryption. It hides nothing: anyone can decode a Base64 string in a second, with no key, which is exactly what the Decode mode of this tool does. Never use it to protect a password or a secret. Second, Base64 is not compression — quite the opposite. The encoded form is about 33% larger than the original, because every 3 bytes of input become 4 characters of output.
How the encoding works
The maths is elegant. Take the input three bytes at a time. Three bytes are 24 bits; split those 24 bits into four groups of 6 bits. Each 6-bit group is a number from 0 to 63, which indexes this alphabet:
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
So index 0 = A, 25 = Z, 26 = a, 51 = z, 52 = 0, 61 = 9, 62 = +, 63 = /. Concatenate the four characters for every 3-byte block and you have the encoding.
Inputs rarely divide neatly by three, so the final partial block is padded with = signs to make a complete group of four characters. One leftover byte produces two alphabet characters plus "=="; two leftover bytes produce three characters plus "=". That is why Base64 strings so often end in = or == — the padding is a visible clue to the length of the original data modulo 3.
Worked example — the tool's own default
The tool opens with the text Hello, World! and Encode mode selected. Its Base64 encoding is:
SGVsbG8sIFdvcmxkIQ==
You can check the first block by hand. The first three bytes are "H", "e", "l" — bytes 72, 101, 108. Written in binary and regrouped into 6-bit chunks, they index the alphabet at S, G, V, s — the first four characters of the output. The whole string is 13 bytes, so it becomes ⌈13 ÷ 3⌉ × 4 = 20 characters including the final "==" (13 = 3×4 + 1, leaving one spare byte, hence two padding characters).
To reverse it, switch the mode to Decode from Base64, paste SGVsbG8sIFdvcmxkIQ== and click Calculate — you get "Hello, World!" back exactly. Three more examples worth recognising, because they show the padding rules cleanly:
| Input | Base64 | Why it ends that way |
|---|---|---|
| M | TQ== | 1 byte → 2 characters + "==" |
| Ma | TWE= | 2 bytes → 3 characters + "=" |
| Man | TWFu | 3 bytes → 4 characters, no padding |
| café | Y2Fmw6k= | the é is 2 bytes in UTF-8, so 5 bytes total |
Decoding a short string by hand
You never need to do this in practice — the tool exists so you don't — but one hand decode makes the system click. Decode TWFu. Find each character's index in the alphabet: T = 19, W = 22, F = 5, u = 46. Write each index as 6 bits: 010011, 010110, 000101, 101110. Join them into one 24-bit stream and re-split it into bytes: 01001101, 01100001, 01101110 — which are the character codes 77, 97 and 110: M, a, n. Encoding is the same road in reverse, which is why the two modes of this tool are exact mirror images and why a string that round-trips unchanged through both is certainly valid.
Where you will meet Base64 in the wild
- Email attachments. MIME email encodes every attachment in Base64, which is why a 10 MB attachment adds roughly 13 MB to a message.
- Data URIs. Small images and fonts embedded directly in HTML or CSS as
data:image/png;base64,…. - API tokens and keys. Many services hand you credentials that are a Base64 string of an underlying value — you decode them to inspect, never to "decrypt".
- JSON Web Tokens (JWTs). The header and payload sections of a JWT are Base64URL-encoded JSON; anyone can read them, which is why tokens must never carry secrets in the payload.
- Basic web authentication. The classic
Authorization: Basic …header is Base64 of "username:password" — readable by design, and only safe over HTTPS.
A note on variants
You may meet Base64URL, which replaces + with − and / with _ and often drops the padding, so the result survives inside a URL without escaping. This tool uses the standard alphabet; if a string you are decoding contains − or _ characters and fails, it is probably the URL-safe variant — swap those two characters back and try again. Line breaks inside a long encoded string (email systems often wrap at 76 characters) are harmless here: the decoder ignores whitespace.
Common mistakes
- Treating Base64 as security. It is a change of alphabet, not a lock. Obfuscation at best; anyone with this very page can reverse it.
- Double-encoding. Encoding an already-encoded string gives a longer string that decodes to Base64, not to your text. If a decode produces more Base64-looking text, decode again.
- Losing the padding. Some systems strip trailing = signs. Many decoders tolerate it, but the strict length rule (output length is always a multiple of 4) is broken without them; this tool's decoder reports an error rather than guessing silently.
- Feeding it a file directly. This is a text tool: paste text to encode, or Base64 text to decode. Encoding an actual binary file (image, PDF) needs a file-capable tool.
- Expecting the same length. Encoded output is always about 4/3 the input size. A "compressed" claim for Base64 is a red flag about whoever made it.
Is my text uploaded anywhere?
No. The conversion runs entirely in your browser with JavaScript — the same code you can inspect in this page. Nothing you paste is transmitted to or stored on a server, which is why the tool works instantly and would work offline. Paste freely, including text you would not type into a server-side service — while remembering the point above: Base64 itself is not protection.
Related tools
The sibling URL Encode / Decode tool handles the other common text transformation (percent-encoding for URLs), and the two are often confused — if your text has % signs everywhere it is URL encoding, if it ends in = padding it is Base64. The general Conversion Calculator covers numeric unit changes.
Frequently asked questions
What does this Base64 tool do?
It converts text to Base64 (Encode mode) or converts Base64 back to the original text (Decode mode). Paste your input, choose the mode, and click Calculate. Everything runs in your browser; nothing is uploaded.
What is the Base64 encoding of "Hello, World!"?
SGVsbG8sIFdvcmxkIQ== — that is the tool's default example. The two equals signs at the end are padding: the text is 13 bytes, and 13 is not a multiple of 3, so the final group is padded to complete the block of four characters.
Does it handle emoji and accented characters?
Yes. The encoder first converts your text to its UTF-8 byte form, so characters outside plain ASCII — accented letters like é, currency symbols, and emoji — encode correctly and decode back exactly. For example, "café" encodes to Y2Fmw6k=.
Is Base64 a way to encrypt or hide text?
No. Base64 is an encoding, not encryption: there is no key, and anyone can decode it instantly (the Decode mode on this page is the proof). Use it to make data safe for transport through text-only systems, never to protect secrets or passwords.
Is my text uploaded to a server?
No. The conversion happens locally in your browser using JavaScript. Your input is never transmitted or stored, which also means the tool works without an internet connection once the page has loaded.
Why does decoding my string give an error?
Usually one of three reasons: the string contains characters outside the Base64 alphabet, its length is not a multiple of 4 (often because the trailing = padding was stripped when it was copied), or it uses the URL-safe variant alphabet (− and _ instead of + and /). Check for those, and make sure you are not trying to decode text that was never encoded.
Does Base64 make my data bigger or smaller?
Bigger — by about a third. Base64 turns every 3 bytes of input into 4 characters of output, so the encoded form is roughly 33% larger than the original. That overhead is the price of carrying binary data and special characters safely through text-only systems.







































