Base64 Encoder Decoder

Output length—

How Base64 Encoder Decoder is calculated: Encode: text → base64 with btoa (3 bytes become 4 characters); decode: base64 → text with atob; invalid input shows an error instead of crashing.

What is base64 encoding?

Base64 is a way to turn any text into a safe string of letters, numbers, and a few symbols. Hello, World! becomes SGVsbG8sIFdvcmxkIQ== — 13 characters in, 20 characters out. The encoded text looks like gibberish, but it is not encrypted: anyone can decode it in a second. Base64 exists to move data safely through plain-text systems, not to hide it.

The need comes up constantly in software. URLs, email headers, and config files can only carry plain text, but the data they carry is often binary — an image, a file, a token. Base64 turns that data into text that survives the journey. A developer who encodes a token sends it safely; a developer who sends raw bytes watches it break.

This tool covers the two jobs people actually need: encode text into base64, and decode base64 back into text. Paste or type your text, pick a mode, and the result appears instantly. Everything runs in your browser — your text never leaves your device, nothing is stored, and there is no account to create.

How base64 encoding works

Base64 works in groups of three bytes. Each group of 24 bits is split into four groups of 6 bits, and each 6-bit group becomes one character from a 64-character alphabet: A to Z, a to z, 0 to 9, plus + and /. That is why the output is always about a third longer than the input — 13 characters of Hello, World! become 20 characters of SGVsbG8sIFdvcmxkIQ==.

The equals signs at the end are padding. If the input is not a multiple of three bytes, the encoder adds one or two = signs to fill the last group. Hello, World! is 13 bytes, and 13 is one more than a multiple of three, so the output ends with ==. Decoding strips the padding and rebuilds the original bytes exactly.

Decoding is the reverse: each character becomes 6 bits, four characters rebuild three bytes, and the padding tells the decoder where the data ends. If the input has a character outside the alphabet, or the wrong length, decoding fails — and this tool shows a plain error message instead of crashing, so you can fix the input and try again.

The 64-character alphabet is the reason for the name: base64 means 64 possible values per character. The letters A to Z cover the first 26 values, a to z cover the next 26, the digits 0 to 9 cover the next 10, and + and / cover the last two. Every character in an encoded string comes from that set, and nothing else. If you see a character outside it — a space, an exclamation mark, a question mark — the string is not base64, and decoding it will fail.

Base64, and where it is actually used

The biggest use is data URLs. A small image can be embedded directly in a web page as base64 text, instead of a separate file. That is how icons and tiny graphics travel inside HTML and CSS. A JSON formatter reads the data that base64 often carries, because JSON is the format most APIs use to move structured data around.

The second use is tokens and credentials. Basic authentication sends username:password as base64 in an HTTP header. JWT tokens carry their payload as base64. API keys are often base64 strings. None of this is encryption — base64 is a coat, not a lock — but it keeps the data intact while it travels.

The third use is email. Email was built for plain text, so attachments are encoded as base64 before sending and decoded on arrival. That is why an email with a photo is about a third bigger than the photo itself. When you need to move text safely through a system that only likes plain characters, base64 is the standard answer.

A worked example: encoding and decoding a greeting

Here is a real situation where base64 earns its keep. You need to send the text Hello, World! inside a URL, but the comma, the space, and the exclamation mark are all characters that URLs handle badly. Encode it first, send it safely.

Paste Hello, World! and pick Encode. The output is SGVsbG8sIFdvcmxkIQ== — 20 characters, all of them safe for a URL, a header, or a config file. The length shown is 20, which is the encoded length, not the original 13. Paste that string back, pick Decode, and you get Hello, World! again — 13 characters, exactly as it started.

Try a bad one. Paste !!! and pick Decode. The tool shows an error message and an output length of 0, because ! is not in the base64 alphabet. That is the right behaviour: a decode that fails loudly is better than one that silently returns garbage. Fix the input, decode again, and the text comes back.

Who uses base64, and why

Developers are the biggest users. Every API token, every data URL, every email attachment passes through base64. A developer who encodes a token sends it safely; a developer who skips the step watches it break in transit.

Testers and support staff are the second group. When a user reports a broken token or a garbled file, the first step is to decode it and read it. A JSON formatter reads the JSON that often hides inside a decoded token, and a word counter can check the size of the same text once it is decoded.

Students and hobbyists are the third group. Anyone learning web development meets base64 in the first month — in data URLs, in auth headers, in JWTs. The tool on this page handles all three uses — paste, pick a mode, copy the result — which covers ninety percent of what anyone needs.

Testers are a fourth group, and they use base64 to build test payloads. A token that has to carry a JSON body, a file that has to travel inside a form field, a string that has to survive a URL — all of them pass through base64 first. Encoding the payload by hand takes a minute and invites a typo; encoding it here takes a second and is always right.

Base64 encoder vs other developer tools

Base64 moves data; other developer tools read it or make it. The same developer-tools family on this site does both jobs. A JSON formatter reads and prints the structured data that base64 often carries. A password generator makes secrets, and base64 is often how those secrets travel.

The difference matters for workflow. Encode last, decode first: if the data is JSON, check it with the formatter before you encode it, and decode it before you read it. Base64 is the envelope, not the letter — it protects the contents in transit, but it does not change what is inside.

Base64 is also the simplest encoding there is — it never changes the data, only its shape. That makes it safe to use and easy to undo. And a case converter answers a different need entirely: styling text for reading, not packaging it for transport.

The size cost is worth knowing before you use it. Base64 output is about a third longer than the input, so a 3 MB image becomes a 4 MB string. For small tokens and short strings that cost is nothing; for large files it adds up, and a direct file upload is the better choice. Encode the small things, upload the big ones. Hexadecimal is the other common text encoding — our hex text converter turns text into hex and back.

Common base64 mistakes

The most common mistake is thinking base64 is encryption. It is not. Anyone can decode a base64 string in a second, so never encode a password or a secret and call it safe. Base64 hides nothing; it only makes data safe to transport. Real secrets need real encryption.

Second: URL-safe base64. Standard base64 uses + and /, which are special characters in URLs. URL-safe base64 replaces them with - and _. If your encoded string goes into a URL and breaks, that is probably why. This tool uses standard base64, which is the version most APIs and tools expect.

Third: forgetting the padding. An encoded string without its trailing = signs may fail to decode in strict tools. If a decode fails and the string looks right, check whether the padding was cut off when it was copied. A missing = is the most common copy-paste error in base64.

Fourth: decoding text that was never encoded. If you paste plain English and pick Decode, the tool will show an error, because plain English is not valid base64. That is the tool working correctly — decode only strings that were actually encoded.

How to use this base64 encoder decoder

Using this base64 encoder decoder is simple. Paste your text into the box, or type it directly. Pick Encode to turn text into base64, or Decode to turn base64 back into text. The result appears instantly in the box below, with its length shown above it. There is no button to press and no form to submit.

To copy the result, use the Copy button next to the output box. To decode what you just encoded, copy the output, paste it back into the input, and switch to Decode. The round trip should return your original text exactly — if it does not, something went wrong in the copy.

Everything runs in your browser. No sign-up, no account, no data sent anywhere — your text never leaves your device. It works offline once the page has loaded, so you can use it on a plane, in a server room with no signal, or anywhere else you debug. Try it with something real before you need it: encode a greeting, then decode it back. Once you have used it twice, you will never hand-encode base64 again.

Frequently Asked Questions

Base64 turns data into a safe string of letters, numbers, and a few symbols so it can travel through systems that only handle plain text — URLs, email headers, config files, and API tokens. It is used for data URLs, basic auth headers, JWT tokens, and email attachments. It is encoding, not encryption: anyone can decode it.

No. Base64 is not encryption and it hides nothing — anyone can decode a base64 string in a second. It only changes the shape of data so it survives transport. Never encode a password or a secret and call it safe; real secrets need real encryption.

The = signs are padding. Base64 works in groups of three bytes, and if the input is not a multiple of three, the encoder adds one or two = signs to fill the last group. Hello, World! is 13 bytes, so its encoding ends with ==. Decoding strips the padding and rebuilds the original text exactly.

The usual causes are a character outside the base64 alphabet, missing padding (= signs cut off when copying), or text that was never encoded at all. Check the string for typos, make sure the padding is intact, and confirm the text actually came from an encoder before decoding it.

More free tools

More calculators and utilities from Sortrun — free, no sign-up.