What is Base64 encoding? A first example with real bytes

Understand the purpose of Base64, see Hello become SGVsbG8=, and recognize the difference between encoding and encryption.

Base64 is a way to represent binary data with ordinary text characters. A picture, a document or a piece of text can all be represented as bytes. When a system needs those bytes inside a text field, Base64 provides a reversible spelling that the receiver can decode later.

A small example

The text Hello contains five ASCII bytes. Encoding those bytes produces SGVsbG8=. Decoding that value returns the same five bytes, which can then be read as the original text. The equals sign belongs to the encoding's final group; it is not part of the word Hello.

Text:           Hello
Bytes in Hex:   48 65 6c 6c 6f
Base64:         SGVsbG8=
Decoded bytes:  48 65 6c 6c 6f

Try the example in the encoder, copy the result into the decoder, and compare the returned text. Then try a Chinese character or emoji. Text must first become bytes using a character encoding such as UTF-8; Base64 itself does not define a language or character set.

Where you encounter it

Common examples include a binary field in JSON, an inline image in a Data URI, and the readable portions of certain tokens. The surrounding format supplies the context. A Base64 string by itself does not tell you the original file name, MIME type, character encoding or whether the content is trustworthy.

A Data URI adds a prefix such as data:image/png;base64,. That prefix describes the payload but is not part of the Base64 alphabet. Some decoders understand the wrapper; others expect only the part after the comma. Choose the appropriate tool or mode instead of deleting unfamiliar characters at random.

Three common misunderstandings

First, Base64 is not encryption: no secret is needed to decode it. Second, it does not make files smaller; ordinary padded output is roughly one third larger than the original bytes. Third, not every decoded result is text. An image may correctly decode to bytes that look like nonsense in a text box.

When a decode fails, check the original source, the chosen alphabet and whether the string was truncated. When it succeeds, choose a suitable view: text for valid text bytes, Hex for inspection, or a file download for binary data. The detailed Base64 alphabet and examples are defined in RFC 4648.