Base64 Encoder

Need to encode string to Base64? This Base64 encoder turns any text, JSON, or binary value into a Base64 string. Paste the input, switch on URL safe Base64 if the value must travel in a URL, and copy the result. The page also shows how to Base64 encode, with a Base64 encode example, padding rules, and line wrapping.

Input · text
0 chars
Line wrap
EOL
Charset

Input 0 B · Output 0 B

Base64 encode turns plain text into the 64-character alphabet used by JSON, email and URLs and shows the result while you type, all in JavaScript inside your browser tab. The text is never posted to a server.

It is the step you need when an API rejects a raw Unicode field, when a log line has to survive a system that strips spaces and line breaks, or when a Basic authentication header must carry user:password without escaping. Paste a sentence in any language and the page returns the encoded string immediately, with byte counts on both sides so the growth is visible rather than guessed. The three switches under the box travel with every copy, which keeps the format consistent across a team.

How to use

  1. Paste the text. Type or paste into the left box, or press Sample to load a mixed string with Latin, Cyrillic and emoji. The output follows every keystroke while Live is checked, and the counter above the box tracks input length.
  2. Set the options. URL-safe swaps + and / for - and _, No padding drops trailing = signs, Line wrap breaks the output every 76 characters (MIME) or 64 (PEM), and Charset decides how the text becomes bytes before encoding.
  3. Copy or download. Copy output places the base64 encode result on the clipboard, Download saves encoded.txt, and the stats line lists input bytes, output bytes and the percentage change.

Alphabet, options and growth

Three controls change the output more than anything else: the alphabet variant, the byte encoding and the line wrapping. Each one has a visible effect on the string you copy.

Inside the base64 encoder

Every three input bytes become four characters from A–Z, a–z, 0–9, + and /, and a final = pads the last group. Hello encodes to SGVsbG8=: five source bytes, eight output characters, a 60% jump caused by the incomplete group. The tool reports the byte count beside both boxes, so a 1,000-byte ASCII text shows roughly 1,364 characters — the 4/3 ceiling. Line wrapping only inserts breaks; it never changes the bytes, and every decoder on this site ignores the whitespace.

How to encode string to base64 with Unicode

Encoding works on bytes, not characters. é is two UTF-8 bytes, so it becomes w6k=; the emoji 👋 is four bytes and becomes 8J+Riw==. Choose UTF-16 and the same word grows again because of the byte-order mark, which is a common reason two teams get different results from identical text. The Charset menu makes that choice explicit, and Auto mode always treats input as UTF-8. If a partner decodes your string and sees question marks instead of letters, their side is reading the bytes as a legacy charset.

URL safe base64 in tokens and query strings

Standard Base64 contains + and /, which change meaning in a query string and break JWT segments. URL-safe mode swaps them for - and _ and usually drops padding: hello? becomes aGVsbG8/ in standard form and aGVsbG8_ in URL-safe form. Enable the switch before copying a token. For Basic auth the value stays standard Base64, not URL-safe; mixing the two is a frequent cause of a 401 that looks like a wrong password. To check a JWT payload, paste its middle segment into the decoder with the URL-safe switch enabled.

FAQ

How to base64 encode text?

Paste the text into the left box and read the result on the right. Encoding starts as you type, no button is needed, and the stats line shows the byte growth. The text stays in the tab, so nothing is uploaded or stored.

Can you show a base64 encode example?

The word Hello becomes SGVsbG8= and hello becomes aGVsbG8=. Both examples end with padding because five bytes do not split evenly into three-byte groups. Paste them into the decoder to confirm the round trip.

Why does the base64 encoder add = at the end?

The equals sign pads the final group to four characters so the decoder knows which bytes are real. One = means two data bytes remain, two means one byte. The No padding option removes them, but strict decoders may then reject the value.

Is my text uploaded to a server?

No. The base64 encode step runs entirely in your browser and the text never leaves the device. That also means the page works offline once loaded, and nothing appears in a server log or analytics event.

Why is the output longer than the input?

Base64 stores six bits in each character, so three bytes need four characters. ASCII text grows by about a third, while UTF-8 text with accents or emoji grows more because those characters already occupy two to four bytes.

Encoding is only half of the round trip. Base64 Decode reverses the string and reports the first invalid character when something is wrong. Base64 Converter keeps both directions on one screen with a Swap button, and Text to Base64 focuses on plain sentences with charset control. Base64 to Image does the opposite job for pictures: it turns a data URI back into a viewable PNG, JPG or SVG image file.