What Is Base64? How to Encode and Decode Text, Explained

November 29, 2026 · Blogs

You have probably met Base64 without realising it. It is the long, slightly alarming string of letters and numbers that turns up inside email code, web addresses, data files and configuration settings — something like SGVsbG8sIFdvcmxkIQ==. It looks like gibberish, and it is meant to. Base64 is simply a way of rewriting ordinary data using only safe, printable characters, so it can travel through systems that would otherwise mangle it.

Lines of programming code in bright colours on a dark screen

Photo: Markus Spiske via Openverse, CC0

What Base64 actually is (and what it is not)

Base64 is an encoding scheme. It takes your original data — text, in the case of our tool — and rewrites it using just 64 characters: the capital letters A to Z, the small letters a to z, the digits 0 to 9, plus the symbols + and /. That is 26 + 26 + 10 + 2, which makes 64. You will also see the equals sign, =, at the end of many Base64 strings. That is not part of the 64; it is padding, added to round the length up neatly.

The maths is tidy. Base64 works in groups: every 3 bytes of your original data become exactly 4 Base64 characters. That is why encoded text is always a bit longer than what you started with — roughly a third longer — and why its length is always a multiple of four.

Here is the point people most often get wrong: Base64 is not encryption. It does not hide or protect anything. Anyone can decode a Base64 string in seconds, with no password and no key, because the method is public and fixed. If you encode a password, you have not made it safe — you have just written it in a different alphabet. Our guide to what makes a strong password explains what actually protects an account. Think of Base64 as putting a letter in an envelope so it survives the post, not locking it in a safe.

Why encoding text is genuinely useful

So why bother? Because plenty of systems were built to handle plain, well-behaved text and nothing else. Email is the classic example: it was designed for simple text characters, so attachments and non-English characters are encoded into Base64 before they are sent, then decoded at the other end. The same trick appears in data URIs, where a small image is embedded directly inside a web page or stylesheet as a long encoded string, and in tokens and settings files that developers copy between systems.

For everyday users, the honest benefits are simpler. Decoding lets you peek at a mysterious string and see whether it is harmless text. Encoding lets you pass a snippet of text — with awkward symbols, spaces or line breaks in it — through a form, a URL or a settings box without it getting chewed up on the way. If you work with APIs, webhooks or email templates, you will run into it sooner or later, and being able to convert both ways on the spot saves a lot of squinting.

The MDN glossary entry on Base64 gives a clear technical overview if you want the deeper background, including how it is used in JavaScript and web development.

How to use the Base64 tool, step by step

  1. Open the tool and decide which way you are going: encoding turns normal text into Base64; decoding turns Base64 back into readable text.
  2. To encode, type or paste your plain text into the box — a word, a sentence, a whole paragraph, whatever you need.
  3. Run the conversion and copy the result. It will be a single string of letters, numbers, + and / characters, possibly ending in one or two = signs.
  4. To decode, paste a Base64 string into the box instead, run the conversion the other way, and read the original text that comes out.
  5. If you are checking someone else’s string, paste the decoded result somewhere safe and read it before you act on it — never trust a string you cannot read.

That is the whole process. You can encode or decode Base64 instantly in your browser, and because it runs on the page, your text is not sent off to be stored anywhere — handy when the snippet contains something you would rather keep to yourself.

Worked examples you can check by hand

Short examples make the pattern obvious. Encode the word “Hi” and you get SGk=. Two characters in, four characters out, with one = of padding to complete the group. Encode “Hello” and you get SGVsbG8= — five letters become eight Base64 characters, again with a single padding sign. A longer greeting, “Hello, World!”, becomes SGVsbG8sIFdvcmxkIQ==, this time with two padding signs at the end.

Notice how the punctuation disappears. The comma, the space and the exclamation mark are all still there in the data — they have just been rewritten using the safe 64-character alphabet. Decode any of those strings and you get the original back, character for character. Nothing is compressed, summarised or lost; it is a perfect round trip, which is exactly what an encoding is supposed to be.

One more useful check: because every 3 bytes become 4 characters, a 300-character piece of plain text will come out at about 400 characters, before padding. If your encoded result is wildly different from that rough ratio, something has probably gone wrong — most often you have encoded the text twice, which is a surprisingly easy mistake to make.

Common mistakes and how to avoid them

Treating Base64 as security

This deserves repeating because it causes real harm. Encoding a password, an API key or personal details in Base64 gives you no protection whatsoever. Anyone who sees the string can reverse it instantly. If something needs protecting, it needs proper encryption or hashing, handled by tools designed for the job.

Broken strings and stray spaces

Decoding fails, or produces nonsense, when the string is incomplete. A copied string that lost its last few characters — or its padding — will not decode cleanly. Copy the whole thing, including any = signs at the end. The opposite problem is extra characters: a line break or space introduced by an email or a wrapped line of text can trip a decoder up, so paste carefully and trim stray spaces.

Encoding twice

If your decoded text still looks like Base64 — random-looking letters ending in = — it was probably encoded twice. Just decode it again. Developers hit this when a value passes through two systems that both helpfully encode it.

Questions people ask

Is Base64 safe for passwords or private information?

No. Base64 is a public, reversible encoding with no key and no secret. Anyone can decode it immediately. Never rely on it to protect passwords, keys or personal data.

Why does Base64 text end in = signs?

The equals sign is padding. Base64 output must be a multiple of four characters long, so one or two = signs are added at the end when the original data does not divide neatly into groups of three bytes. “Hi” becomes “SGk=” — the = completes the group of four.

Why is the encoded version longer than the original?

Because every 3 bytes of original data are rewritten as 4 characters. That fixed ratio means Base64 output is always about a third longer than the input, plus any padding.

Base64 stops being mysterious the moment you have converted a few strings yourself. Encode a sentence, decode it back, and try decoding one of the examples above to check you get the original wording. Once that round trip clicks, you will recognise Base64 everywhere — and you will know exactly what it can and cannot do.

Tags: base64, developer tools, encoding, text tools