How to encode text to Base64
- Type or paste your text into the Input box, or open a file.
- Choose the character set (UTF-8 works for every language and emoji), URL-safe output or 76-character line breaks if you need them.
- Copy the Base64 result or download it as a text file.
How Base64 encoding works
The encoder takes your text as bytes, splits them into groups of 3 bytes (24 bits) and turns each group into 4 characters from a 64-character alphabet. If the last group is incomplete, = signs are added as padding. That is why Base64 output is about 33% larger than the input: Man becomes TWFu.
Base64 encoding in popular languages
- JavaScript:
btoa(String.fromCharCode(...new TextEncoder().encode(text))) - Python:
base64.b64encode(text.encode()).decode() - PHP:
base64_encode($text) - Java:
Base64.getEncoder().encodeToString(text.getBytes(UTF_8)) - Linux/macOS:
echo -n 'text' | base64
Frequently asked questions
Why is the Base64 result longer than my text?
Base64 stores 3 bytes in 4 characters, so the output is roughly 4/3 of the input size, plus padding. Non-Latin characters take 2–4 bytes in UTF-8, which makes their Base64 longer still.
What do the = signs at the end mean?
They are padding. One = means the last group had 2 bytes, two == mean it had 1 byte. URL-safe Base64 often omits them.
Can I encode emojis and non-English text?
Yes. Keep the character set on UTF-8 and any language, symbol or emoji is encoded correctly and can be decoded on any system.
When should I enable line breaks every 76 characters?
Only for email (MIME) and some PEM certificates, which require wrapped lines. For APIs, JSON, URLs and data URIs keep it off.