Base64 encoder

Encoding(auto)
95 B → 128 B
Text to encode95 B
Base64
RW5jb2RlIGFueSB0ZXh0IOKAlCBpbmNsdWRpbmcgYWNjZW50cywg5L2g5aW9LCBhbmQgZW1vamkg8J+OiSDigJQgb3IgcGFzdGUgQmFzZTY0IHRvIGRlY29kZSBpdC4=
Input95 B
Output128 B
Overhead+35%
StatusValid

Base64 Encoder and Decoder

Encode text to Base64 or decode it back, with the direction detected from what you paste. URL-safe output, optional padding, MIME line wrapping, and a data URI wrapper are all one switch each — and a malformed string is told what is wrong with it rather than silently producing nothing.

What Base64 costs in size
+33%
Characters out per bytes in
4:3
MIME line length
76
Bytes uploaded
0

Step by step

How to use it

  1. 01Paste either form

    The direction is detected: text that looks like valid Base64 is decoded, anything else is encoded. Override it whenever the guess is wrong — a word like data can legitimately be both.

  2. 02Choose the alphabet

    Standard Base64 uses + and /. URL-safe swaps them for - and _, which is what you need in a query string, a path segment, or a JWT — where the standard characters would be percent-encoded or misread.

  3. 03Decide about padding and wrapping

    Padding with = keeps the length a multiple of four, which some strict decoders require and JWTs deliberately omit. Wrapping at 76 characters is what MIME asks for in email bodies.

  4. 04Wrap it as a data URI if it is going in a document

    The data: prefix with a MIME type turns the string into something a browser will render directly — an inline stylesheet, a small file, a preview.

Worked example

Where the 33% comes from

Base64 is not compression and it is not encryption — it is a fixed re-encoding of three bytes into four printable characters. The arithmetic below is the whole mechanism.

Given

Input
"Man" (3 bytes)
Bits
24
Alphabet
64 characters, 6 bits each

Three bytes, twenty-four bits, four characters

M        a        n
01001101 01100001 01101110      24 bits
010011 010110 000101 101110     regrouped into 6s
19     22     5      46         values
T      W      F      u          -> "TWFu"

3 bytes in, 4 characters out. Always.
Size change
+33.3%
Padding needed
0, 1, or 2 =
Security added
none

Every three bytes become four characters, so the output is exactly a third larger, and when the input is not a multiple of three the encoder pads to keep the block size — one = for two leftover bytes, two = for one. Nothing about this is secret: Base64 is trivially reversible by anyone, which is why finding credentials Base64-encoded in a config file is a finding, not a mitigation.

Before you use it

What to know about Base64

It is an encoding, not encryption

Anyone can decode it in one step, with no key and no effort. Base64 exists to move binary data through channels that only accept text — email bodies, JSON strings, URLs, HTML attributes. Credentials stored this way are stored in plain sight.

URL-safe is a different alphabet, not an option

Standard Base64 uses + and /, both of which mean something else in a URL. The URL-safe variant substitutes - and _ and usually drops the padding. A decoder expecting one alphabet will reject or mangle the other, which is why the switch exists on both sides here.

Padding is required by some decoders and forbidden by others

The = characters make the length a multiple of four. Strict decoders insist on them; JWTs and many URL-safe schemes deliberately strip them. If a string decodes here but not in your code, padding is the first thing to check.

Line wrapping is for email, and browsers ignore it

MIME requires Base64 broken at 76 characters in message bodies. HTML, CSS, and JSON ignore the newlines entirely, so one wrapped string can serve an email template and a stylesheet — but a strict command-line decoder may need the whitespace stripped first.

Text is encoded as UTF-8 bytes

Base64 operates on bytes, not characters, so text has to become bytes first. Accents, emoji, and non-Latin scripts encode correctly here because UTF-8 is used throughout — a mismatch in that step is the usual cause of mojibake after a round trip through another tool.

Everything runs locally

Encoding and decoding both happen in your browser, which matters because the strings people decode are usually tokens, credentials, and payloads pulled out of logs. Nothing is uploaded, and short inputs travel in a share link only if you choose to share one.

The judgement call

Which variant do you need?

Base64 is one idea with several incompatible conventions layered on top. This is which to reach for.

  • A value in a query string or a path

    URL-safe, unpadded

    + and / are reserved in URLs and = often is too. The URL-safe alphabet avoids percent-encoding entirely.

  • Inspecting a JWT segment

    URL-safe, unpadded

    JWT uses base64url with padding stripped. Standard decoding will fail on the same string.

  • An attachment or an email body

    Standard, wrapped at 76

    MIME asks for the standard alphabet and 76-character lines.

  • Inlining a small file in HTML or CSS

    Data URI

    The prefix carries the MIME type, which is what tells the browser how to read the bytes.

  • Storing a password or an API key

    Not Base64

    It hides nothing from anyone. Use a secret manager, or hashing where you only need to verify.

  • Making a payload smaller

    Wrong tool

    Base64 makes data a third larger. Compress first if size matters, then encode if the channel demands text.

Reference

How the encoding is defined

Ratio
4 characters per 3 bytesA fixed 33% expansion, plus padding. Not compressible, and identical for every input.
Standard alphabet
A–Z a–z 0–9 + /The original RFC 4648 set, with = as padding.
URL-safe alphabet
A–Z a–z 0–9 - _Substitutes the two characters that are unsafe in URLs; padding is usually omitted as well.
Padding
= or ==One for two leftover bytes, two for one. Required by strict decoders, dropped by JWT and most URL-safe schemes.
MIME wrapping
76 charactersRFC 2045, for email bodies. Ignored by HTML, CSS, and JSON parsers.
Text handling
UTF-8 bytesCharacters become bytes before encoding, so accents, emoji, and non-Latin scripts survive a round trip.

FAQ

Questions, answered plainly

How do I decode a Base64 string?

Paste it in — a string that looks like valid Base64 is decoded automatically. Both alphabets are accepted, whitespace and line breaks are ignored, and missing padding is tolerated, so a JWT segment or a wrapped email body decodes without cleaning it up first.

Is Base64 encryption?

No. It is a reversible encoding with no key, and anyone can decode it in a single step. Its purpose is to move binary data safely through text-only channels such as email bodies, JSON, and URLs. Credentials that are merely Base64-encoded are stored in plain sight.

What is URL-safe Base64?

A variant that swaps + and / — both reserved in URLs — for - and _, and usually drops the = padding. It is what JWTs and most token formats use. A standard decoder fed a URL-safe string will typically fail or produce the wrong bytes, so the alphabet has to match on both sides.

Why is my decoded output empty or garbled?

The three usual causes are a truncated string, a mismatched alphabet, and a character lost in copying. Valid Base64 uses only its 64-character alphabet and has a length that is a multiple of four once padded — if either test fails, the tool names which one rather than showing you nothing.

Why is my Base64 bigger than the original?

Because it encodes every three bytes as four printable characters — a fixed 33% expansion, plus a padding character or two. That is the price of representing arbitrary bytes using only characters that survive text-based channels intact.

Is my data uploaded?

No. Encoding and decoding both run in your browser, which matters because the strings people decode are usually tokens, credentials, and payloads pulled out of logs. Nothing is transmitted or stored.

Encoding and decoding both run in your browser. Nothing is uploaded, logged, or retained — which matters when the string is a token or a credential.