← All TOOLZORQ tools · More guides

What Is Base64 Encoding and How Do You Encode Text to Base64?

30 November 2026

Short answer: Base64 is a way of writing any bytes — text, an image, a file — using only 64 safe characters (A–Z, a–z, 0–9, + and /), so binary data can travel through systems built for plain text, like email, JSON and URLs. To encode text, paste it into TOOLZORQ's Base64 Encoder / Decoder and click Encode; to get the original back, paste the Base64 string and click Decode.

You have almost certainly seen Base64 without knowing it. It is the long jumble of letters, numbers and equals signs at the end of an email attachment, inside a website's login token, or in the middle of an image embedded directly into a web page. It looks like secret writing, but Base64 hides nothing: anyone can decode it in a second, with no key and no password. It is not encryption — it is a change of alphabet, a way of rewriting data so it survives a journey through places that only accept plain text.

What is Base64 encoding?

Base64 is a binary-to-text encoding scheme. Computers store everything as bytes, but many of the systems that move data around were built for text only, and they choke on certain byte values. An email system, a JSON document, an HTTP header or a web address can only carry a limited set of characters safely, and a raw image contains byte values those systems would corrupt or reject.

Base64 solves this by re-writing any bytes using only 64 characters that are safe almost everywhere: the capital letters A to Z, the small letters a to z, the digits 0 to 9, and the two symbols + and /. A 65th character, the equals sign =, is used as padding at the end when the input does not divide neatly. The standard is defined in RFC 4648, so an encoder written in one language and a decoder written in another agree on the result — Hello always becomes SGVsbG8=, whether you encode it in a browser, in Python or on the command line.

How does Base64 encoding work?

The trick is a change of grouping. A byte holds 8 bits. A Base64 character holds 6 bits, because 64 possible values is exactly 2 to the power of 6. The encoder works in blocks of 3 bytes (24 bits) at a time and rewrites each block as 4 characters. So Base64 output is always a multiple of 4 characters long, and roughly a third bigger than the input.

Here is a worked example, encoding the text Hi!. H is 72, i is 105 and ! is 33. As 8-bit binary, side by side, that is 01001000 01101001 00100001. Cut the 24 bits into four groups of 6 — 010010 000110 100100 100001 — and look each group up in the alphabet, where A is 0 through Z is 25, a is 26 through z is 51, 0 is 52 through 9 is 61, + is 62 and / is 63:

6-bit groupValueCharacter
01001018S
0001106G
10010036k
10000133h

So Hi! encodes to SGkh — check it with printf 'Hi!' | base64 in a terminal. Decoding runs the same steps backwards: each character back to its 6-bit value, the bits joined, then cut every 8 bits into bytes.

How to encode text to Base64 with TOOLZORQ

The fastest way to encode a piece of text is TOOLZORQ's free Base64 Encoder / Decoder. It runs entirely in your browser, needs no sign-up, and nothing you paste ever leaves your device. Step 1: open the tool. Step 2: type or paste your text into the input box. Step 3: click Encode. Step 4: copy the result and paste it wherever you need it — an email, a JSON field, a configuration file, a URL parameter.

Try it with Hello, World! and you will get SGVsbG8sIFdvcmxkIQ==. Try سلام and you will get 2LPZhNin2YU=; try 😀 and you will get 8J+YgA==. All three work because the tool converts the text to UTF-8 bytes first — the step many simple encoders skip.

How to decode Base64 back to text

Decoding is the same tool in reverse. Paste the Base64 string into the Base64 Encoder / Decoder, click Decode, and the original text appears. Paste SGVsbG8sIFdvcmxkIQ== and you get Hello, World! back.

A decoder needs well-formed input, and three things commonly go wrong. First, missing padding: some systems strip the trailing = signs — add them back until the length is a multiple of 4. Second, the wrong variant: if the string contains - and _ instead of + and /, it is Base64URL, and a standard decoder may reject it. Swap - back to + and _ back to / before decoding.

Base64 examples: what common text looks like encoded

Short inputs show the padding rules: 1 byte in gives == padding, 2 bytes give =, and 3 bytes give none.

Original textBase64Notes
AQQ==1 byte in, == padding
ABQUI=2 bytes in, = padding
ABCQUJD3 bytes in, no padding
HelloSGVsbG8=5 bytes in, 8 characters out
Hello, World!SGVsbG8sIFdvcmxkIQ==13 bytes in, 20 characters out
سلام2LPZhNin2YU=Urdu: 8 UTF-8 bytes, 12 characters
😀8J+YgA==One emoji: 4 UTF-8 bytes, 8 characters

The same input always gives the same output — there is no randomness and no key. And the output gives no clue about the input beyond a rough length: SGVsbG8= could be any 5-byte text.

Why does Base64 make data about 33% bigger?

The size cost follows directly from the 3-to-4 ratio. Every 3 bytes of input become 4 characters of output, so the encoded length is 4 × ceil(n ÷ 3) characters for n bytes of input — about 33% more, plus up to two padding characters. 1 KB (1,024 bytes) becomes 1,368 characters, and 100 KB becomes about 136,536 characters. A small image embedded in a web page as a data URI is convenient — it saves a separate download — but a large image encoded this way is a third bigger than the file itself. The same applies to email: an attachment sent as Base64 is a third larger than the file on your disk. If size matters, compress the data first and encode it after — Base64 never makes anything smaller.

What is the = padding at the end?

The = signs at the end of many Base64 strings are padding, and they exist because the encoder works in groups of 3 bytes. When the input length is not a multiple of 3, the last group is short, and the encoder fills the missing bits with zeros and adds one = for each missing output character, so the total length stays a multiple of 4. A remainder of 2 when the input length is divided by 3 gives one = (Hello → SGVsbG8=); a remainder of 1 gives two == (A → QQ==); an exact multiple of 3 needs none (ABC → QUJD). Padding carries no information of its own — it is a marker telling the decoder how many bits in the final group were filler. Some systems, notably URLs and JWT tokens, drop the padding because the length of the original data is known another way, or because = is awkward in a URL.

Base64 vs Base64URL: the variant that matters on the web

Standard Base64 has a problem in web addresses: two of its characters, + and /, have special meanings in URLs. A + in a query string reads as a space, and a / reads as a path separator. Base64URL, defined in the same RFC 4648 specification, fixes this by swapping + for - and / for _, and usually dropping the = padding as well. For example, subjects?id=42 encodes as c3ViamVjdHM/aWQ9NDI= in standard Base64 but c3ViamVjdHM_aWQ9NDI in Base64URL. The two variants encode the same bytes, but they are not interchangeable — a standard decoder fed a Base64URL string will fail on the - and _ characters. If you are putting encoded data into a URL, a filename or a cookie, use the URL-safe variant; everywhere else, standard Base64 is the default.

Where you will see Base64 in real life

Base64 is infrastructure — it does its work out of sight, and you meet it in several everyday places. Email attachments: email was designed for plain text, and the MIME standard (RFC 2045) chose Base64 as the way to carry attachments through it. When you send a photo by email, your mail program encodes the image as Base64 text; the recipient's program decodes it back into the file. Images embedded in web pages: a data URI lets a page carry a small image inside its own code — data:image/png;base64,iVBORw0KGgo.... JSON and APIs: JSON has no way to carry raw bytes, so when an API needs to accept or return a file inside a JSON document, it encodes the file as Base64. If you work with JSON, TOOLZORQ's JSON Formatter guide explains how to check that a document containing Base64 values is valid. Login tokens: a JSON Web Token (JWT) is three Base64URL-encoded parts joined by dots — a header, a payload and a signature.

Base64 is not encryption — the mistake that matters most

The single most important thing to understand about Base64 is what it is not. Encoding only changes how data is written: no key, no password, no secret — anyone who recognises the output can reverse it in a second. A password stored as Base64 is a password stored in plain text with extra steps.

Never use Base64 to protect anything. Do not encode a password and call it secure, and do not encode a secret and paste it somewhere public. If something needs to be secret, encrypt it with a real encryption method and a key — and if you need a strong password in the first place, generate one with TOOLZORQ's Password Generator instead of disguising a weak one. The confusion is understandable, because Base64 output looks unreadable. But unreadable and secret are different things: Base64 is useful for transport and useless for secrecy.

The Unicode trap: why emoji and Urdu text break naive encoders

The classic Base64 bug appears the moment text leaves plain English. JavaScript's built-in btoa() function, for example, only accepts Latin-1 characters — hand it Urdu text or an emoji and it throws an error, because those characters do not fit in a single byte. The fix is to turn the text into UTF-8 bytes first, and encode those bytes. In UTF-8, plain English letters take one byte each, Urdu letters take two, and most emoji take four. That is why سلام (4 letters) becomes 8 bytes and encodes to 12 Base64 characters, while a single 😀 (1 character) becomes 4 bytes and encodes to 8 characters. TOOLZORQ's Base64 Encoder / Decoder does this conversion for you, which is why Urdu text and emoji encode and decode correctly in it.

How to encode and decode Base64 in code

Every major language has Base64 built in, so you rarely need to write the algorithm yourself. In JavaScript, btoa() encodes and atob() decodes — but they only handle Latin-1 text, so convert through UTF-8 first with TextEncoder and TextDecoder. In Python, the base64 module works on bytes: base64.b64encode('Hello, World!'.encode('utf-8')) gives b'SGVsbG8sIFdvcmxkIQ==', and base64.b64decode() reverses it. On the command line, printf 'Hello' | base64 prints SGVsbG8=, and printf 'SGVsbG8=' | base64 -d prints Hello. Use printf rather than echo, so no extra newline is added.

Frequently asked questions

What is Base64 encoding used for?

Moving binary data through text-only systems: email attachments, images embedded in web pages as data URIs, files inside JSON documents, and login tokens (JWTs).

Is Base64 encryption?

No. Base64 is encoding, not encryption. It changes how data is written, not who can read it. There is no key, and anyone can decode it. Never use it to protect passwords, secrets or personal data.

How do I decode Base64 to text?

Paste the Base64 string into TOOLZORQ's Base64 Encoder / Decoder and click Decode. The original text appears instantly.

Why does my Base64 end with = signs?

Those are padding. Base64 works in groups of 3 input bytes, and when the input does not divide evenly, = signs fill the last group so the output length stays a multiple of 4.

Why is my Base64 output longer than my text?

Because every 3 bytes of input become 4 characters of output — about 33% larger. That is the price of writing binary data with only 64 safe characters.

Can Base64 handle Urdu text and emoji?

Yes, if the encoder converts the text to UTF-8 bytes first. TOOLZORQ's encoder does this, so Urdu and emoji work.

Base64 is a small idea with an outsized job: it lets the internet's text-only pipes carry anything at all. Once you know the alphabet, the 3-to-4 rhythm and the padding rule, the mysterious strings stop looking mysterious — they are just ordinary data, rewritten in 64 safe characters so it can travel.