What is Base64
Base64 is a way to represent binary data using only 64 text-safe characters (A-Z, a-z, 0-9, + and /). It's widely used to embed images in CSS/HTML, transmit data in APIs, and encode credentials in HTTP headers.
Base64 is not encryption
Important: Base64 only encodes, it doesn't encrypt. Anyone can decode Base64 instantly — don't use it to protect sensitive information.
Padding with = and final length
"Man" (3 bytes) becomes TWFu; "Ma" (2 bytes) becomes TWE=; "M" becomes TQ==. The = fills the last block so the length is a multiple of 4. A 100-byte input yields 136 characters.
An accented example
"olá" in UTF-8 has the bytes 6F 6C C3 A1 and encodes to b2zDoQ==. If the receiving side reads the decoded bytes with an encoding other than UTF-8, the "á" shows up garbled.
The URL-safe variant
Tokens and URL parameters often use Base64Url, which swaps + for - and / for _, and frequently drops the =. If a Base64 string refuses to decode, check whether it is that variant and whether it contains line breaks: the MIME format inserts one every 76 characters.
Images embedded in CSS and HTML
A small image can be inlined as data:image/png;base64,.... Because Base64 inflates size by about a third, this pays off only for tiny files such as icons; large images get heavier and lose separate caching. When decoding such a string, strip everything up to and including the comma first, since only the part after it is Base64 data.
Frequently asked questions
Is Base64 safe for passwords?
No. Base64 isn't encryption — it's just an alternative representation, reversible by anyone.
Why does Base64 make text longer?
Because every 3 original bytes become 4 Base64 characters, roughly a 33% increase.