Base64 in Plain Text: What It Is and Why It Grows by a Third
Quick answer
Base64 is a way to write binary data as plain ASCII text. It turns every 3 bytes into 4 characters, so the text is about a third larger than the original. A trailing = or == is padding: it tells a decoder the last group was short. Base64 is not encryption, and anyone can decode it.
What base64 is and why it exists
Some channels only carry text. Email, XML and data: URLs are the examples MDN's Base64 glossary entry gives. Binary data such as an image or a key can't be pasted into them directly, so base64 rewrites it using 64 safe printable characters. The data arrives intact, and the receiver turns it back into bytes.
That's all it does. There's no key and no secret, so it's an encoding, not encryption. If you find a long run of letters and digits in a note, a config file or a log, it may well be base64, and it is readable by anyone who decodes it. Text-heavy files have their own pitfalls too, as in UTF-8 and line breaks in mixed-language text files.
How three bytes become four characters
RFC 4648, the standard that defines base64, describes the process in section 4. Take 3 bytes (3 × 8 = 24 bits), treat those 24 bits as four groups of 6 bits, and turn each 6-bit group into one character.
The 64-character alphabet
Six bits can hold 64 different values (2 to the 6th power), and the alphabet has exactly 64 characters:
A-Z values 0 to 25
a-z values 26 to 51
0-9 values 52 to 61
+ value 62
/ value 63MDN lists the same alphabet and notes that = is used as a padding character alongside it.
A worked example
The three letters Cat are the bytes 0x43, 0x61 and 0x74:
Bytes: 01000011 01100001 01110100
Regroup: 010000 110110 000101 110100
Values: 16 54 5 52
Output: Q 2 F 0So Cat becomes Q2F0. Three characters in, four characters out.
Why base64 grows by a third
Every 3 input bytes produce 4 output characters, a ratio of 4 to 3. MDN states it this way: the base64 version of a string or file is typically roughly a third larger than its source. The exact growth depends on the length, its remainder when divided by 3, and whether padding is used.
This matters for notes and snippets. A 30 KB image pasted as base64 becomes about 40 KB of text. Short inputs grow a little more, because padding adds characters that carry no data.
What the = padding means
Input length is not always a multiple of 3. When fewer than 24 bits are left at the end, RFC 4648 says zero bits are added on the right to fill the 6-bit groups, and = characters complete the final group of four. The standard lists exactly three cases:
- A multiple of 3 bytes: no padding.
- One byte left over: two characters followed by
==. - Two bytes left over: three characters followed by
=.
All three, side by side:
Cat -> Q2F0
Ca -> Q2E=
C -> Qw==Count the = signs and you know how many bytes were in the last group. One = means two bytes, == means one byte.
The extra zero bits matter too. MDN's example is the single byte 0b01010101, which needs two characters: V (0b010101) and Q (0b010000). The second character carries 4 trailing bits set to zero. RFC 4648 requires encoders to set them to zero, and decoders may optionally reject a string where they aren't.
Can you drop the padding? Not by default. RFC 4648 says implementations must include it unless the specification that refers to it says otherwise. Check what the receiving tool expects before you trim a string by hand.
Line breaks and the URL-safe variant
Two variants change what you see in plain text.
Line breaks. MIME limits base64 lines to 76 characters, and PEM uses 64, according to RFC 4648's discussion of line feeds. The standard itself says implementations must not add line feeds unless the referring specification asks for them. Wikipedia's Base64 article works out that MIME-style output, line breaks included, is usually about 137% of the original length. If a blob wraps at a fixed width, that is why. Any line-based format you put it in needs the same care you'd give quoting rules in CSV or one JSON record per line.
URL-safe base64. RFC 4648 section 5 defines an alphabet that swaps + and / for - and _, so the string can sit in a URL or file name. MDN adds that this version omits the padding. If a string has - or _ and no = at the end, it is probably this variant.
How Carets fits in
Base64 blobs end up in notes, config files and snippets, and it helps to see what they are before you paste them somewhere. Carets is a fast, native notes and code editor for iPhone, iPad, and Mac. It keeps everything as plain text, so a long encoded string stays portable and searchable, and you can organize snippets into files, projects and tags. Syntax highlighting for code and config files makes it easier to tell an encoded value from the keys around it. Carets doesn't decode base64 for you; it gives you a tidy place to keep the text.
Get Carets on the App Store for iPhone, iPad, and Mac.
Frequently Asked Questions
Is base64 encryption?
No. It is a reversible encoding with a public alphabet, and anyone can decode it. Its job is to carry binary data over text-only channels, not to hide it.
Why does my base64 string end in =?
The input length wasn't a multiple of 3 bytes. One = means the last group had 2 bytes, and == means it had 1 byte.
Can I drop the = padding?
RFC 4648 says padding must be included unless the specification referring to it says otherwise. The URL-safe variant omits it, so check what the receiving tool expects.
How much bigger is base64 than the original?
About a third larger, because 3 bytes become 4 characters. Adding line breaks every 76 characters, as MIME does, brings the total to about 137% of the original.