Home/Other Calculators & Tools/Base64 Encoder / Decoder

Base64 Encoder & Decoder

Free · No sign-up · Runs entirely in your browser, nothing sent to a server

Encode text to Base64 or decode it back — with full UTF-8 support and the URL-safe alphabet used by JWTs and APIs accepted automatically.

Input
Output
Encoded
⏱️ Last reviewed: 26 July 2026 · Written and reviewed by Mohsin Iqbal under our editorial policy and calculation methodology.
Base64 is not encryption. Anyone can decode it instantly — this page does it in one click. Never use it to protect passwords, tokens, keys or personal information. It converts data so it survives transmission; it does not conceal anything.
📖 Approx. 11 min read🔒 Runs in your browser🔄 Updated 26 July 2026

On this page

  1. Encoding Is Not Encryption
  2. How Base64 Actually Works
  3. The 64-Character Alphabet
  4. The Two Alphabets
  5. Examples to Try
  6. Where You Will Actually Meet It
  7. Data URIs and the Size Penalty
  8. Unicode, UTF-8 and Why Some Tools Break
  9. In Code
  10. Common Mistakes
  11. Frequently Asked Questions
  12. Useful, and Not Remotely Secret

🔑 Key Takeaways

Encoding Is Not Encryption

This is the point worth getting right before anything else, because getting it wrong causes real breaches.

Encoding (Base64)EncryptionHashing
PurposeMake data transmissibleMake data unreadableVerify integrity or identity
Needs a keyNoYesNo
ReversibleYes, by anyoneOnly with the keyNo, by design
Provides secrecyNone at allYesNot applicable
ExamplesBase64, URL encoding, hexAES, RSA, TLSSHA-256, bcrypt, Argon2
HTTP Basic Authentication is the classic trap. It sends your username and password as a single Base64 string — which looks scrambled and is not. YWRtaW46cGFzc3dvcmQ= decodes to admin:password in a fraction of a second. Basic Auth is only safe over HTTPS, where TLS provides the actual encryption. Over plain HTTP the credentials are effectively in the clear, and anyone on the network path can read them.

If you need secrecy, encrypt. If you need to store a password, hash it with a slow algorithm designed for the purpose. Base64 is neither, and treating it as either is a serious mistake. For generating credentials worth protecting, see our password generator.

How Base64 Actually Works

The mechanism is simple once you see it. Base64 regroups bits: it takes three bytes of 8 bits and re-slices them into four groups of 6 bits.

Input:   M        a        n
Bytes:   01001101 01100001 01101110
Regroup: 010011 010110 000101 101110
Values:   19     22     5      46
Output:   T      W      F      u

"Man" → TWFu

Six bits can hold 64 values, which is where the name comes from. Those values map to a fixed alphabet: A–Z (0–25), a–z (26–51), 0–9 (52–61), then two more — + and / in the standard alphabet.

Input lengthOutputPadding
3 bytes4 charactersNone
2 bytes4 charactersOne =
1 byte4 charactersTwo ==
That is what the equals signs are for. Base64 output always comes in blocks of four characters, so when the input does not divide evenly by three, padding fills the gap. The = is not part of the data — it just marks how many bytes the final block actually contains. This is also why encoded data grows: four characters carry what three bytes did, a 33% increase, plus up to two padding characters.

The 64-Character Alphabet

Every 6-bit group maps to one of these. The two highlighted rows are the only difference between the standard and URL-safe variants.

#Char#Char#Char#Char
0A16Q32g48w
1B17R33h49x
2C18S34i50y
3D19T35j51z
4E20U36k520
5F21V37l531
6G22W38m542
7H23X39n553
8I24Y40o564
9J25Z41p575
10K26a42q586
11L27b43r597
12M28c44s608
13N29d45t619
14O30e46u62+ → -
15P31f47v63/ → _

Values 0–25 are A–Z, 26–51 are a–z, 52–61 are 0–9, and the last two are + and / — or - and _ in the URL-safe alphabet.

Only two characters differ between the alphabets — positions 62 and 63. That is the entire distinction, and it is why converting between them is a two-character find-and-replace. It also explains why a string containing neither +, /, - nor _ is valid in both, which is why many short Base64 strings decode fine either way.

The Two Alphabets

RFC 4648 defines two variants, and mixing them up is the most common practical problem with Base64.

Standard (§4)URL-safe (§5)
Character 62+-
Character 63/_
Padding= requiredOften omitted
Used inEmail attachments, data URIs, general encodingJWTs, URL parameters, filenames, API tokens
Why the URL-safe variant exists. In a URL, + means a space and / separates path segments — so standard Base64 inside a URL either breaks or has to be escaped again. Swapping those two characters solves it. The same applies to filenames, where / is a path separator on every operating system.

This tool accepts both when decoding, and restores missing padding automatically. Paste a JWT segment, an OAuth token or a URL parameter and it will decode without you needing to convert it first. When encoding, the URL-safe form is shown beneath the output whenever it differs.

Examples to Try

Paste any of these into the tool above. Every value below was generated and verified rather than typed.

What it isInputBase64
Plain textHello WorldSGVsbG8gV29ybGQ=
JSON payload{"user":"alice","admin":false}eyJ1c2VyIjoiYWxpY2UiLCJhZG1pbiI6ZmFsc2V9
UTF-8 with accentscafé façadeY2Fmw6kgZmHDp2FkZQ==
EmojiG'day 🇦🇺RydkYXkg8J+HpvCfh7o=
HTTP Basic Authadmin:passwordYWRtaW46cGFzc3dvcmQ=

A real JWT payload, in base64url with the padding stripped — exactly as it appears in a token. Paste it into the decoder to see it work:

eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkphbmUgQ2l0aXplbiIsImFkbWluIjp0cnVlfQ

That decodes to {"sub":"1234567890","name":"Jane Citizen","admin":true} — readable by anyone who has the token, which is the point worth remembering about JWTs.

Try the Basic Auth example. Decode YWRtaW46cGFzc3dvcmQ= and you get admin:password immediately. That string is exactly what an HTTP Authorization header carries, and seeing how fast it comes back is the most convincing argument that Base64 protects nothing.

Where You Will Actually Meet It

ContextWhat Base64 is doing
JSON Web TokensThe header and payload are base64url-encoded JSON. Anyone can read them — the signature provides integrity, not secrecy
Email attachments (MIME)Email was designed for 7-bit text. Base64 lets binary attachments survive it, wrapped at 76 characters per line
Data URIsEmbedding a small image directly in HTML or CSS: data:image/png;base64,iVBORw0…
HTTP Basic AuthUsername and password joined by a colon, then encoded. Readable by anyone — safe only over HTTPS
API payloadsSending binary data such as files or images inside JSON, which cannot carry raw bytes
Configuration and secretsKubernetes secrets, for instance, are Base64-encoded — which is encoding, not protection
Certificates (PEM)The text between BEGIN and END markers is Base64-encoded binary

Data URIs and the Size Penalty

Embedding an image as a data URI removes an HTTP request, which sounds like a straightforward win. The trade-off is size.

Original imageAs Base64Verdict
1 KB icon~1.37 KBUsually worth it — saves a request
10 KB logo~13.7 KBBorderline; depends on caching
100 KB photo~137 KBRarely worth it
1 MB image~1.37 MBNo — use a normal image file
The hidden cost is caching. A separate image file is cached by the browser and reused across pages. An embedded data URI is part of the HTML or CSS, so it downloads again with every page that includes it and cannot be cached independently. It also blocks rendering while it parses. The rule of thumb: embed tiny icons that appear on one page, and link everything else normally.

Unicode, UTF-8 and Why Some Tools Break

Base64 encodes bytes, not characters — so any text has to become bytes first, and that step is where many tools fail.

JavaScript's built-in btoa() only accepts characters in the range 0–255. Feed it an emoji, a Greek letter or Chinese text and it throws an error. The fix is to convert the text to UTF-8 bytes first, which is what this tool does.

TextUTF-8 bytesBase64
Hi2SGk=
café5 — é takes twoY2Fmw6k=
日本語9 — three each5pel5pys6Kqe
😀48J+YgA==

Notice that "café" is four characters but five bytes, and a single emoji is four bytes. That is UTF-8: common Latin characters take one byte, accented characters two, most CJK three, and emoji four. The calculator above reports both counts so the difference is visible.

In Code

LanguageEncodeDecode
JavaScriptbtoa(unescape(encodeURIComponent(s)))decodeURIComponent(escape(atob(b)))
Pythonbase64.b64encode(s.encode())base64.b64decode(b).decode()
Python (URL-safe)base64.urlsafe_b64encode(...)base64.urlsafe_b64decode(...)
PHPbase64_encode($s)base64_decode($b)
Command lineecho -n "text" | base64echo "dGV4dA==" | base64 -d
Two things to watch in scripts. The -n in the shell example matters — without it, echo adds a newline that gets encoded along with your text, producing a different string than you expected. And in JavaScript, the escape and unescape functions above are deprecated; modern code uses TextEncoder and TextDecoder, though the older idiom still works everywhere.
Browser support. This tool uses btoa() and atob(), which have been in every browser for well over a decade — Chrome, Firefox, Safari, Edge and their mobile versions all support them, with no plugin or permission required. UTF-8 text is converted to bytes before encoding, which is what allows emoji and non-Latin scripts to work where a plain btoa() would fail. Since there is no server involved, the tool also works offline once the page has loaded — and will not run at all with JavaScript disabled.

Common Mistakes

  1. Treating Base64 as security. It offers none. Anyone can decode it in one click, including this page.
  2. Mixing the two alphabets. Standard Base64 in a URL breaks; URL-safe Base64 fails in decoders that only accept + and /.
  3. Stripping padding and then decoding strictly. Many decoders reject input whose length is not a multiple of four. This tool restores the padding for you.
  4. Forgetting the 33% size increase. Base64-encoding a large file inside JSON inflates it by a third, plus JSON's own escaping.
  5. Encoding text without deciding the byte encoding. Base64 works on bytes. The same text in UTF-8 and UTF-16 produces entirely different output.
  6. The trailing newline from echo. A missing -n silently changes the result, and the mismatch is invisible until something fails to authenticate.
  7. Assuming a JWT is encrypted. Its header and payload are base64url-encoded and readable by anyone. The signature proves the token has not been altered — it does not hide the contents.

Frequently Asked Questions

What is Base64?

Base64 is an encoding scheme that represents binary data using 64 printable characters — A–Z, a–z, 0–9 and two symbols. It exists so that binary data can pass through systems designed only for text, such as email or JSON. It regroups every three bytes into four characters, which is why encoded data is about a third larger.

Is Base64 encryption?

No. Base64 provides no security whatsoever. It requires no key and anyone can reverse it instantly — this page does it in one click. Encryption uses a key and is unreadable without it. If you need to protect data, encrypt it; if you need to store a password, hash it with an algorithm designed for that purpose.

Why is Base64 used?

Because many systems only handle text safely. Email was built for 7-bit characters, JSON cannot carry raw bytes, and URLs treat certain characters specially. Base64 converts binary data into a form that survives all of them intact, at the cost of about 33% extra size.

What is the difference between standard and URL-safe Base64?

The standard alphabet uses + and / for the last two characters; the URL-safe variant defined in RFC 4648 section 5 uses - and _ instead, and often drops the = padding. This matters because + means a space in a URL and / separates path segments. JWTs and most modern APIs use the URL-safe form. This tool accepts both and restores missing padding automatically.

Why does my Base64 string end in equals signs?

Base64 output comes in blocks of four characters representing three bytes. When the input does not divide evenly by three, padding fills the remainder — one = if two bytes remain, two == if one byte remains. The padding is not data; it just marks how many bytes the final block holds.

How much larger does Base64 make data?

Roughly 33%, because four characters carry what three bytes did, plus up to two padding characters. A 100 KB image becomes about 137 KB. This matters when embedding images as data URIs or sending files inside JSON payloads, and it is one reason large files are usually sent as separate binary uploads.

Can Base64 encode images?

Yes — that is what a data URI does, embedding the image directly in HTML or CSS as data:image/png;base64 followed by the encoded bytes. It saves an HTTP request but adds about a third to the size and prevents the browser caching the image separately. Worth it for tiny icons, rarely worth it above about 10 KB.

Why does Base64 fail on emoji or accented characters?

Base64 encodes bytes, not characters, so text must be converted to bytes first. JavaScript's built-in btoa() only accepts characters in the range 0–255 and throws an error on anything else. The solution is to convert to UTF-8 bytes before encoding, which this tool does — emoji, accented characters and CJK scripts all round-trip correctly.

Is a JWT encrypted?

No. A JWT's header and payload are base64url-encoded JSON that anyone can decode and read. The signature proves the token was issued by someone holding the signing key and has not been altered since — that is integrity and authenticity, not confidentiality. Never put sensitive data in a JWT payload.

Are Kubernetes secrets encrypted?

Not by default. Kubernetes secrets are Base64-encoded, which prevents formatting problems in YAML but provides no protection at all — anyone who can read the secret object can decode it instantly. Protecting them requires encryption at rest, appropriate access controls, or an external secrets manager.

Why does my command-line Base64 differ from this tool?

Almost always a trailing newline. Running echo "text" without the -n flag appends a newline character, which gets encoded along with your text and produces a different string. Use echo -n, or printf, to encode exactly what you intended.

Is this tool safe for sensitive data?

Everything runs in your browser — nothing is transmitted, logged or stored, and you can verify that by disconnecting from the internet and watching it still work. That said, remember what Base64 is: encoding it does not protect anything. If the data is genuinely sensitive, the question is whether it should be encoded at all rather than encrypted.

Useful, and Not Remotely Secret

Base64 does one job well: it lets binary data travel through channels built for text. It costs about a third in size and provides exactly zero confidentiality — and understanding that second point is what separates a useful tool from a security incident.

For related tools, the URL encoder and decoder handles the different problem of reserved characters in web addresses, and the password generator creates credentials that genuinely are protected.

🌐 Internet & Tech Tools

Base64 Encoder / Decoder — text to Base64 and back (this page) URL Encoder / Decoder — percent-encoding for web addresses Password Generator — strong random passwords IP Subnet Calculator — CIDR, network and host ranges Bandwidth Calculator — transfer times and data usage

📋 References & Further Reading

RFC 4648 — The Base16, Base32 and Base64 data encodings MDN Web Docs — Base64 and binary data in JavaScript RFC 2045 — MIME, including Base64 for email RFC 7519 — JSON Web Tokens