Base64 Encoder & Decoder

Encode text/files to Base64 or decode back. Works with UTF-8 characters.

What is Base64?

Base64 is a way of representing binary data using only 64 printable ASCII characters. It exists because many systems - email, URLs, JSON, XML - were designed to carry text and mishandle arbitrary binary data.

It is an encoding, not encryption. Anyone can decode Base64 instantly, and it provides no confidentiality whatsoever. Its purpose is safe transport, not secrecy.

Key takeaways

  • Base64 uses A-Z, a-z, 0-9, + and /, with = as padding.
  • Encoded output is about 33% larger than the input.
  • It is not encryption - decoding requires no key and takes milliseconds.
  • URL-safe Base64 replaces + and / with - and _.
  • Common uses: email attachments, data URIs, JWTs, and binary data in JSON.

How the encoding works

Base64 takes three bytes of input - 24 bits - and splits them into four groups of six bits. Each six-bit group indexes into a 64-character alphabet, producing four output characters.

  1. Take 3 input bytes: 24 bits total.
  2. Split into 4 groups of 6 bits.
  3. Map each 6-bit value (0-63) to a character in the Base64 alphabet.
  4. If the input is not a multiple of 3 bytes, pad the output with = signs.

Because 3 bytes become 4 characters, the output is always 4/3 the size of the input - roughly a 33% increase. This is the unavoidable cost of representing binary data in a text-safe form.

InputLengthBase64 outputPadding
Man3 bytesTWFuNone
Ma2 bytesTWE=One =
M1 byteTQ==Two ==
Hello5 bytesSGVsbG8=One =

The = padding tells the decoder how many bytes of the final group were real data rather than zero-fill.

Base64 is not encryption

Never use Base64 to protect anything. It has no key, no secret and no security property. Decoding it is a single function call available in every programming language and in every browser's developer console. Storing a password, API key or personal data "encoded in Base64" gives exactly the same protection as storing it in plain text, with the added risk that it looks protected to a casual observer.
Encoding (Base64)Encryption (AES)Hashing (SHA-256)
PurposeSafe transportConfidentialityIntegrity / fingerprinting
Requires a key?NoYesNo
Reversible?Yes, by anyoneYes, with the keyNo
Provides secrecy?None at allYesNot applicable

Where Base64 is genuinely used

  • Email attachments. MIME encodes binary attachments as Base64 because SMTP was designed for 7-bit text.
  • Data URIs. Embedding a small image directly in CSS or HTML as data:image/png;base64,... saves an HTTP request.
  • JSON Web Tokens. Each of the three JWT segments is URL-safe Base64.
  • HTTP Basic authentication, which Base64-encodes the username and password - which is precisely why it must only be used over HTTPS.
  • Binary data in JSON or XML, neither of which can carry raw bytes.
  • Certificates and keys in PEM format, which wrap Base64 in header and footer lines.
Data URIs have a size limit worth respecting. Embedding an image as Base64 removes an HTTP request, which helps for tiny icons. For anything larger it hurts: the file grows 33%, it cannot be cached separately, and it blocks rendering of the stylesheet or document containing it. A few kilobytes is a sensible ceiling.

Standard versus URL-safe Base64

Standard Base64 uses + and /, both of which have special meaning in URLs and would need percent-encoding. URL-safe Base64 substitutes them.

CharacterStandardURL-safe
Index 62+-
Index 63/_
Padding=Often omitted entirely

JWTs use URL-safe Base64 without padding, which is why a JWT segment can be decoded by standard tools only after converting the characters back.

UTF-8 and non-English text

Base64 operates on bytes, not characters, so text must be converted to bytes first. For anything beyond basic ASCII, that conversion must be UTF-8 - and getting it wrong is the most common Base64 bug.

  • A naive JavaScript btoa() call throws an error on any character above U+00FF.
  • The correct approach encodes to UTF-8 bytes first, then Base64-encodes those bytes.
  • This tool handles UTF-8 correctly, so emoji, accents and CJK text all round-trip cleanly.
Everything runs in your browser. This tool is implemented entirely in client-side JavaScript. Nothing you enter is transmitted to a server, logged or stored, which matters a great deal for anything security-related. You can verify this yourself by opening your browser's network tab and watching it stay empty while you work.

Frequently Asked Questions

What is Base64 encoding?

A method of representing binary data using 64 printable ASCII characters - A to Z, a to z, 0 to 9, plus and slash. It exists so binary data can pass safely through systems designed to carry text, such as email, JSON and URLs.

Is Base64 encryption?

No, absolutely not. It has no key and no secret, and decoding it takes a single function call available in every language and every browser console. It provides no confidentiality at all - it is a transport format, not a security measure.

Why is Base64 output larger than the input?

Because three bytes of input become four output characters, making the result about 33 percent larger. That expansion is the unavoidable cost of representing arbitrary bytes using only a restricted set of text-safe characters.

What do the equals signs at the end mean?

They are padding. Base64 works in groups of three input bytes, so when the input length is not a multiple of three, one or two equals signs are added to tell the decoder how many bytes in the final group were real data.

What is URL-safe Base64?

A variant that replaces the plus with a hyphen and the slash with an underscore, because both original characters have special meaning in URLs. Padding is often omitted too. JSON Web Tokens use this variant.

Can Base64 handle emoji and non-English text?

Yes, provided the text is converted to UTF-8 bytes before encoding. This is the most common source of Base64 bugs - JavaScript's built-in btoa function fails on characters above U+00FF unless you encode to UTF-8 first. This tool handles it correctly.

Should I embed images as Base64 data URIs?

Only small ones. Embedding removes an HTTP request, which helps for tiny icons. For larger images it hurts: the file grows 33 percent, it cannot be cached independently, and it blocks rendering of the document containing it. A few kilobytes is a reasonable limit.

Why is HTTP Basic authentication considered insecure?

Because it merely Base64-encodes the username and password, which anyone intercepting the request can decode instantly. It is only acceptable over HTTPS, where the transport layer provides the actual protection.

Is my data sent to a server?

No. Encoding and decoding happen entirely in your browser. Nothing is transmitted, logged or stored.

Related Calculators