TextBase64

13 bytes → 20 Base64 characters

Try

How it's encoded

Every 3 bytes become four 6-bit values, one per character
Bytes (hex)Bits in groups of 6ValuesBase64
48 65 6C010010 000110 010101 10110018 6 21 44SGVs
6C 6F 2C011011 000110 111100 10110027 6 60 44bG8s
20 77 6F001000 000111 011101 1011118 7 29 47IHdv
72 6C 64011100 100110 110001 10010028 38 49 36cmxk
21001000 0100008 16IQ==
Guide

How to encode and decode Base64

  1. Type text into the Text box to encode it, or paste Base64 into the Base64 box to decode it. Both boxes update as you type.
  2. To encode, the text becomes UTF-8 bytes, every 3 bytes (24 bits) are split into four 6-bit values, and each value picks one of 64 characters. Man becomes TWFu.
  3. Turn on URL-safe for tokens and links, or turn off Padding to drop the = signs at the end.

Worked example

Encoding Man: its 3 bytes are 24 bits, split into four groups of 6.

6 bitsValueCharacter
01001119T
01011022W
0001015F
10111046u

Man → TWFu

  • Base64 is an encoding, not encryption. Anyone can decode it, so never use it to hide passwords.
  • Encoded data is about a third larger than the original, because every 3 bytes become 4 characters.
  • Pasting a data URL? The data:…;base64, prefix is removed automatically.
Learn

How Base64 encoding works

Six-bit groups, padding, URL-safe Base64 and where you'll run into it.

Email attachments, data URLs and login tokens all carry binary data as plain text, and that's what a Base64 encode and decode tool is for: it turns any data into letters, digits and a few symbols, and back again. Type in either box above to encode text to Base64 or decode Base64 to text, with every 6-bit group shown. Below is how Base64 works bit by bit, why it ends with = signs, and where you'll run into it.

What Base64 is

Base64 represents binary data using only 64 printable characters. Many systems, like email, JSON, XML and URLs, were built for text and can mangle raw bytes, so Base64 gives a safe way to carry images, files, keys and other binary data through them. The name comes from the alphabet size: 64 is 2⁶, so each Base64 character carries exactly 6 bits. The standard alphabet is:

ValuesCharacters
0–25A–Z
26–51a–z
52–610–9
62+
63/

How Base64 encoding works

Base64 works on groups of 3 bytes. Three bytes are 24 bits, and 24 bits split evenly into four groups of 6. Each 6-bit group is a number from 0 to 63, and that number picks a character from the alphabet. Take Man. Its bytes are 77, 97 and 110, or 01001101 01100001 01101110. Regrouped in sixes, that's 010011 010110 000101 101110, which is 19, 22, 5 and 46, and those values are the characters T, W, F and u. So Man encodes to TWFu. Text is first turned into UTF-8 bytes, so emoji and accented letters work too: 👋 encodes to 8J+Riw==. The text to binary converter shows the bytes of any text.

Why Base64 ends with = or ==

When the data isn't a multiple of 3 bytes, the last group is short. The encoder adds zero bits to fill the final 6-bit value, and then adds = signs so the output is still a multiple of 4 characters. One leftover byte gives two characters and ==, and two leftover bytes give three characters and =:

  • Man → TWFu
  • Ma → TWE=
  • M → TQ==

The padding carries no data, so many systems leave it out. This tool decodes Base64 with or without it, and the Padding switch controls whether the encoder adds it.

Decoding Base64 by hand

Decoding runs the same steps backwards. Look up each character's value, write the values as 6-bit groups, join them, and read the bits back in groups of 8. TWFu is 19, 22, 5 and 46, which gives 010011 010110 000101 101110, or the bytes 77, 97 and 110: Man. With padding, the extra zero bits are thrown away. TQ== is 19 and 16, or 010011 010000. The first 8 bits, 01001101, are 77, the letter M, and the last four zeros were only padding.

Base64 makes data about 33% bigger

Every 3 bytes of input become 4 characters of output, so Base64 is 4/3 the size of the original, roughly a third larger. A 1 MB image becomes about 1.33 MB of Base64. That's the price of making binary data safe for text channels, and it's why large files are usually sent as real attachments or downloads rather than inlined as Base64.

URL-safe Base64

Two characters of the standard alphabet, + and /, have special meanings in URLs and file names. URL-safe Base64, also called Base64URL, swaps them for - and _ and usually drops the padding. In that form 👋 becomes 8J-Riw. JSON Web Tokens (JWTs) use it: the header {"alg":"HS256","typ":"JWT"} encodes to eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9, which is why so many tokens start with eyJ. This decoder accepts both alphabets.

Where you'll see Base64

  • Data URLs. Small images can be embedded in HTML and CSS as data:image/png;base64,…. Every PNG starts with iVBORw0KGgo, the Base64 form of its 8-byte signature.
  • Email attachments. MIME encodes attachments in Base64 so they survive mail servers built for text.
  • HTTP Basic authentication. The browser sends user:pass as dXNlcjpwYXNz. That's why Basic auth must only be used over HTTPS.
  • Keys and certificates. PEM files wrap Base64 between lines like -----BEGIN CERTIFICATE-----.

Base64 isn't encryption

Base64 has no key and no secret. Anyone can decode it in a second, as this page shows, so it hides nothing. Use it to transport data, and use real encryption, like TLS or AES, to protect it.

Troubleshooting Base64

  • Line breaks and spaces in pasted Base64 are ignored, so wrapped email or PEM text decodes fine.
  • If the decoded result isn't valid UTF-8, the data is probably binary, like an image or a compressed file, rather than text.
  • To see the same bytes in hex or binary, use the hex converter or the binary translator.

Keep one size rule in mind: Base64 output is about four-thirds the size of the input, so a 3 MB file becomes roughly 4 MB of text.

FAQ

Frequently asked questions

Quick answers about the base64 encode & decode and how it works.

What is Base64?

Base64 is a way to write any data, including binary files, using 64 safe characters: A–Z, a–z, 0–9, + and /. Each character carries 6 bits, so every 3 bytes become 4 characters. It's used to send images, attachments and keys through systems built for text.

How do I decode Base64?

Paste it into the Base64 box and the decoded text appears in the Text box. Spaces and line breaks are ignored, the padding is optional, and URL-safe Base64 with - and _ works too. SGVsbG8= decodes to Hello.

Why does Base64 end with = or ==?

Base64 works in groups of 3 bytes. When the last group has only 1 or 2 bytes, the output is padded with == or = so its length stays a multiple of 4. M encodes to TQ== and Ma to TWE=.

Is Base64 encryption?

No. Base64 has no key, so anyone can decode it instantly. It changes how data is written, not who can read it. To protect data, encrypt it, for example with HTTPS or AES.

What is URL-safe Base64?

It's Base64 with - instead of + and _ instead of /, usually without padding, so the result can go in URLs and file names. JSON Web Tokens use it. Turn on URL-safe to encode this way. The decoder reads both forms.

Why is the decoded result unreadable?

The Base64 probably contains binary data, like an image, a PDF or compressed bytes, rather than text. The tool warns you when the decoded bytes aren't valid UTF-8. If it's a data URL, the type after data:, such as image/png, tells you what the data is.

Still have a question?Contact us