Skip to content
← Back to Blog
Base64EncodingDeveloper ToolsString Tools

Base64 Encoder and Decoder: What It Is and When to Use It

People searching for base64 encode usually need one of two things: convert a string right now, or understand the jumble of letters they are staring at. This article does both, and it is blunt about the one thing most people get wrong — Base64 is an encoding, not encryption. You can encode and decode Base64 in the browser, or read on for what is actually happening.

RMBG.PRO string tools for encoding and decoding Base64

Published on September 19, 2026

Base64 is a way of representing any bytes using only 64 printable characters: the upper- and lower-case letters A–Z and a–z, the digits 0–9, and the two symbols + and /, with = used as padding at the end. Feed text in, get a longer string of those characters back. Feed that string back in, get the exact original bytes.

The reason it exists is that a surprising amount of the world still expects text, not bytes — and specifically a safe subset of text. Raw binary data is full of control characters, null bytes, and high values that get mangled or rejected the moment it passes through a system built for ASCII. Base64 translates everything into characters that survive that journey.

Three properties matter when you use it, and they explain almost every Base64 problem you will ever hit. It is reversible — decoding gives back the identical bytes, always. It is bigger — roughly 33% larger than the input. And it is not security — there is no key, and anyone can decode it.

The rest of this article walks through why the alphabet looks the way it does, how padding works, how to encode and decode, the pitfalls that break accented text and URLs, and where you will meet Base64 in real systems. If you only need the conversion, the Base64 tool does it instantly and entirely in your browser.

Why Does Base64 Exist at All?

The problem is older than the web. Email was designed to carry plain ASCII text. When people wanted to send a photograph or a compiled program through it, the raw bytes caused chaos: a byte valued at 10 was interpreted as a line break, a byte at 0 terminated the message early, and values above 127 were simply redefined by whichever system received them. The message that arrived was not the message that was sent.

Base64 solves this by mapping every possible byte value onto characters that text systems handle without surprises. Because there are only 64 of them, and all 64 are ordinary printable ASCII, the output can be typed, pasted, emailed, stored in a config file, or embedded in a JSON document without any byte being misinterpreted along the way.

That same property keeps being reinvented. Modern formats have the same weakness in different clothing: JSON cannot hold raw binary, URLs cannot safely hold arbitrary bytes, and HTML attributes cannot embed an image. Each time, the answer is the same encoding, because the constraint is the same — the channel wants text.

The Alphabet, the Padding, and the 33% Overhead

The mechanism is arithmetic, not magic. Base64 takes the input bytes and reads them in groups of three. Three bytes is 24 bits, and 24 bits split into four 6-bit chunks gives exactly four numbers — each between 0 and 63, which is why there are 64 characters. Each 6-bit number is looked up in the alphabet to become one character. Four characters out for every three bytes in.

That ratio is where the size penalty comes from: four characters replace three bytes, so the encoded text is about 33% longer than the raw input. Base64 is not compression, and treating it as if it were is a quick way to bloat your payloads.

Input lengths do not always divide by three, which is what the = padding is for. The final short group is padded so the output length stays a multiple of four, and decoders read the padding to know how many real bytes the last group held:

InputBytesBase64Padding
abc3YWJjnone — exact multiple of 3
ab2YWI=one = — last group held 2 bytes
a1YQ==two = — last group held 1 byte

Two consequences are worth memorising. First, Base64 output is always a multiple of four characters in length — if yours is not, something has already gone wrong. Second, the encoding is case-sensitive: YWJj and ywjj are different strings, so you cannot lowercase a Base64 value and expect it to still decode.

Encoding and Decoding, Step by Step

The single most common mistake happens before any Base64 is involved: forgetting that Base64 encodes bytes, not text. When you encode a string, it is first converted to bytes using a character encoding — in practice always UTF-8 on the modern web — and those bytes are what Base64 represents.

Take the word Hello. Its UTF-8 bytes are encoded to give SGVsbG8=. Decode SGVsbG8= and you get those same five bytes back, which read as “Hello” again. Hi becomes SGk=, and Hello, World! becomes SGVsbG8sIFdvcmxkIQ== — the double padding appearing because the input is 13 bytes, which leaves a single byte in the final group.

For anything interactive, the fastest path is the Base64 encoder and decoder. Paste text to get Base64, or paste Base64 to get text back — including characters outside ASCII, which the tool handles as proper UTF-8. It also belongs to the wider set of string tools for counting words, converting case, and encoding URLs.

If you are doing this in code, the standard library of nearly every language has it built in, and the function names are usually obvious — btoa and atob in the browser, base64.b64encode in Python, Base64.getEncoder() in Java. The pitfall is the same in all of them: mind the boundary between text and bytes.

The Pitfalls That Bite People

Base64 itself is simple. The edge cases around it are what waste afternoons.

  • Accented characters and emoji. Because Base64 encodes bytes, an accent is more than one byte in UTF-8. The French word café encodes to Y2Fmw6k= — the trailing w6k is the two bytes of é. If a decoder reads those bytes as a single-byte charset instead of UTF-8, the accent becomes mojibake. If your accents look wrong after a round trip, this is why.
  • Line breaks inside the data. Email conventions wrap Base64 at 76 characters and insert line breaks, which are not part of the encoding. A value copied out of an email or certificate may decode incorrectly or fail entirely until those breaks are stripped first.
  • Standard versus URL-safe alphabets. The ordinary alphabet’s + and / are unsafe in URLs and file names. The URL-safe variant, Base64URL, swaps them for - and _ and usually drops the padding. A token that “looks like Base64” but will not decode is frequently just the other alphabet.
  • Padding that breaks APIs. Some systems reject the = padding, while others require it. JSON Web Tokens omit it entirely. When two services disagree, the exact same value works with one and fails with the other.
  • Treating it as encryption. Base64 hides nothing. It is a publicly known, keyless transformation that any decoder reverses in microseconds. We will come back to this, because it is the one mistake with real security consequences.

Most of these share a single root cause: Base64 is defined over bytes, and every one of these failures is a disagreement about which characters are allowed, or about how bytes map back to text. Get that boundary right and the rest follows.

Where You Actually Meet Base64

You do not have to look for Base64 — it shows up on its own. Recognising it by sight is a genuinely useful skill, because half the battle is knowing what you are holding.

  • Data URLs. The data:image/png;base64,… prefix embeds an image directly in HTML or CSS as one long Base64 string, trading an extra request for a larger document. Useful for small icons, counterproductive for large images.
  • Email attachments. SMTP still carries attachments as Base64 inside the MIME structure, which is where the line-wrapping convention comes from.
  • JSON Web Tokens. A JWT is three Base64URL segments joined by dots — header, payload, signature. Anyone can decode the middle segment and read the claims, which is by design: the token is signed, not encrypted.
  • HTTP basic authentication. The Authorization: Basic header sends credentials as username:password encoded in Base64 — a perfect illustration of why encoding is not protection, since it is trivially decoded.
  • API payloads and config. Anywhere a system needs binary data inside a text format: image uploads over JSON, source maps, secrets in CI variables, embedded certificates.

The diagnostic habit worth building is simple: when you see a dense block of letters, digits, +, / and trailing =, or - and _ with no padding, test it as Base64 first. Paste it into the decoder and see whether readable text comes out.

Base64 Is Not Security

This deserves its own section because it is the mistake with consequences. Encoding a secret in Base64 provides zero confidentiality. The algorithm is published, there is no key, and decoding is instant and free. Storing a password or API key as Base64 is the same as storing it in plain text with extra steps — it only hides the value from a human glancing at the screen, never from anyone who looks for more than a second.

The same logic applies to JWTs, which are a frequent source of confusion. A JWT’s payload is readable by anyone who holds the token — that is how it is designed to work. The signature guarantees the token was not tampered with; it does not encrypt the contents. If you need the contents hidden, that is a different problem requiring actual encryption.

On the privacy side there is one genuinely positive thing to know. When a tool runs entirely in your browser, the text you paste never reaches a server. The RMBG.PRO Base64 tool is built this way, so decoding Base64 without uploading anything is not a promise to trust — it is simply how the page works. For anyone handling credentials, tokens, or customer data, that distinction matters.

The rule of thumb: use Base64 freely for transport and representation, and never for secrecy. When in doubt, assume anything you have only Base64-encoded can be read by anyone who receives it — because it can.

Encode or Decode Without the Guesswork

Whatever you need Base64 for, the conversion itself should be the easy part:

  • A free Base64 encoder and decoder that handles UTF-8 text, including accents and emoji.
  • Runs entirely in your browser — nothing you paste is uploaded.
  • Part of the wider string tools set: word counter, character counter, case converter, and URL encoder.
  • No signup, no install, and nothing to configure before you paste.

Try the Base64 Tool

Paste text, get Base64. Paste Base64, get text. It runs in your browser, so it never leaves your machine.

Encode / Decode Base64

Frequently Asked Questions

Is Base64 encryption?▾

No. Base64 is an encoding, not encryption. It is fully reversible, uses no key, and the algorithm is public — anyone who has the Base64 string can decode it back to the original bytes. Encryption hides data from anyone without the key; Base64 just represents the same bytes in a restricted set of characters. Never use Base64 to protect a secret.

Does Base64 compress data?▾

No, it does the opposite. Base64 converts every 3 bytes into 4 characters, so the output is about 33% larger than the input. It exists to move bytes safely through text-only channels, not to make them smaller. If you need smaller data, compress first (for example with gzip) and then encode the compressed bytes.

Why does a Base64 string end with = signs?▾

Padding. Base64 works in groups of 3 bytes (24 bits) that become 4 characters. When the input length is not a multiple of 3, the final group is short, and = characters fill the empty positions so the output length is always a multiple of 4. One = means the last group held 2 bytes; two = means it held 1 byte. Decoders rely on this to reconstruct the exact original length.

What is the difference between Base64 and Base64URL?▾

Standard Base64 uses + and /, which are unsafe inside a URL or query string. Base64URL (defined in RFC 4648) replaces + with - and / with _, and usually drops the = padding as well. JSON Web Tokens use the Base64URL alphabet for all three of their segments. If a token you are decoding looks like Base64 but fails, a plus-sign or slash mismatch is a likely cause.

Can a Base64 string contain characters that break a URL?▾

Yes — standard Base64 can. The + and / characters have special meanings in URLs, and = padding can also cause trouble, so a raw Base64 string placed in a query string may be mangled or rejected. Either use the Base64URL alphabet, or percent-encode the Base64 string before putting it in a URL. The double-encoding bug this causes is a common debugging headache.

Is it safe to paste text into an online Base64 decoder?▾

It depends entirely on whether the tool runs in your browser or sends the data to a server. The RMBG.PRO Base64 tool runs client-side, so the text you paste is encoded and decoded in your own browser and is not uploaded anywhere. That said, because Base64 is not encryption, you should still avoid pasting real secrets like passwords or API keys into any web tool — encoding them does not hide them.

Similar articles

View all