Base64 Encoder & Decoder

Encode text to Base64 or decode it back, with URL-safe output and full Unicode support. Runs entirely in your browser.

How to use this calculator

  1. 1Choose encode or decode.
  2. 2Paste your text or Base64 string.
  3. 3Switch on URL-safe output if the result is going into a URL, filename or JWT.

How the calculation works

Every 3 bytes (24 bits) → 4 Base64 characters (6 bits each)
6 bits
Each Base64 character encodes 6 bits, giving an alphabet of 64 symbols
=
Padding, added when the input length is not a multiple of 3

The alphabet is A–Z, a–z, 0–9, + and /. URL-safe Base64 swaps the last two for - and _.

The 4:3 character-to-byte ratio is why Base64 always inflates data by roughly one third. This is the cost of making binary safe for text-only channels.

Text is UTF-8 encoded before Base64 is applied, so non-ASCII characters — accents, emoji, CJK — round-trip correctly.

Worked example

Encoding "Hello, world!"

  1. 1.The text is 13 bytes in UTF-8.
  2. 2.13 is not divisible by 3, so the final group is padded.
  3. 3.The result is SGVsbG8sIHdvcmxkIQ== — 20 characters including two padding marks.

Result: SGVsbG8sIHdvcmxkIQ==

What Base64 encoding actually is

Base64 is a way of representing arbitrary binary data using only 64 printable ASCII characters — the upper- and lowercase letters, the digits 0–9, and two more symbols (+ and /, or - and _ in the URL-safe variant). It does this by regrouping the data’s bits: three bytes (24 bits) are reinterpreted as four 6-bit chunks, and each chunk is mapped to one character from the 64-character alphabet.

The result is longer than the original — about a third longer, since 4 output characters replace every 3 input bytes — but it can travel safely through systems that were only ever designed to carry plain text.

Why it exists: making binary safe for text-only channels

Base64’s origins are practical, not academic. Early internet protocols like SMTP (email) were built around 7-bit ASCII text and could mangle or strip anything outside that range — a problem the moment people wanted to attach a photo or a document to an email, since image and file data is arbitrary binary, not text. The MIME standard adopted Base64 in the early 1990s specifically to solve this: encode the attachment’s bytes as text, send it through the text-only pipe, decode it back to bytes on the other end.

The same underlying problem — a channel that only reliably carries text — shows up constantly in modern software, which is why Base64 outlived the email systems it was designed for.

  • Data URIsembedding a small image or font directly inside a CSS file or HTML page as data:image/png;base64,… rather than as a separate file request.
  • JWTseach segment of a JSON Web Token — header, payload and signature — is Base64url-encoded so the token can be passed safely in a URL or an HTTP header.
  • Basic authenticationthe HTTP Authorization header encodes a username:password pair in Base64 before sending it (which is why Basic auth must always run over HTTPS — encoding is not protection).
  • Embedding binary in JSON or XMLboth formats are text-only, so binary content like a certificate or a small file has to be Base64-encoded to fit inside a string field.

Not encryption — a common and consequential mix-up

Base64 is an encoding, not a cipher. It has no key, no secret, and nothing to keep private — anyone who sees the encoded string can decode it in a single step, using nothing more than a public, standardized lookup table. It exists purely to change the representation of data, not to protect it.

Treating Base64 as if it hid or secured data is a genuine, recurring security mistake, sometimes called "security by Base64." A password or API key that is merely Base64-encoded rather than encrypted is exactly as exposed as if it were sent in plain text — the encoding only changes what it looks like, not who can read it.

What this assumes, and where it stops

Assumptions

  • Input text is interpreted as UTF-8.

Limitations

  • Handles text, not binary files. Encoding an image requires reading its bytes, which this text-based tool cannot do.
  • Decoding data that was not originally UTF-8 text will produce replacement characters, because the bytes cannot be interpreted as text.

Common questions

Is Base64 encryption?

No, and treating it as such is a genuine security mistake. Base64 is a reversible encoding with no key — anyone can decode it instantly. It exists to move binary data safely through text-only channels like email and URLs, not to hide anything.

What is URL-safe Base64?

A variant that replaces + with - and / with _, and usually drops the = padding, because those three characters have special meaning in URLs. JWTs use it for every segment. This tool produces it when you switch on the URL-safe option.

Why is my encoded string longer than the original?

Base64 uses 4 characters for every 3 bytes, so the output is always about 33% larger. That overhead is the price of representing arbitrary bytes using only safe printable characters.

Sources

Formula and content last reviewed on .

Results are estimates for information only, not professional advice.

Report an error

Tools people commonly use alongside the base64 encoder & decoder.

See all developer tools calculators →