Glossary

Base64

Base64 encoding

Base64 is a binary-to-text encoding that represents bytes with a 64-character alphabet.

Definition

Base64 is a binary-to-text encoding for carrying arbitrary bytes through systems designed for text. The standard alphabet contains uppercase and lowercase Latin letters, digits, +, and /; = may appear at the end as padding.

Base64 changes how data is represented, not what it means. It provides no secrecy, authentication, or integrity by itself and can be decoded without a key.

How it works

The encoder takes 3 input bytes, treats their 24 bits as four 6-bit values, and maps each value to one of 64 characters. If the final group has only 1 or 2 bytes, the missing portion is commonly marked with = padding so the output length is a multiple of four.

For large inputs, the encoded form is about one third larger than the original bytes. Base64url replaces + and / with - and _ and is often used without padding; it is a related variant, not always interchangeable with standard Base64.

Practical example

The ASCII and UTF-8 bytes for Hi are 48 69 in hexadecimal. Standard Base64 represents those two bytes as SGk=. Decoding restores the same bytes; interpreting them as UTF-8 then produces the text Hi.

This distinction matters because Base64 can also contain an image, compressed data, or ciphertext. A successful decode does not guarantee readable text.

Formats and pitfalls

Applications must agree on the Base64 variant, whether padding is required, and whether whitespace is permitted. A decoder may reject a string accepted by a more tolerant implementation. Text must first be converted to bytes with a character encoding such as UTF-8; choosing a different encoding can produce a different Base64 string.

Frequently asked questions

No. Base64 is a public, reversible encoding and needs no secret key. Encrypt sensitive data with an appropriate cryptographic scheme before representing its bytes as Base64.

Padding fills the last four-character group when the input length is not divisible by three bytes. One or two padding characters can occur; some formats omit them.

They use the same 6-bit grouping, but Base64url substitutes URL-safe characters and commonly omits padding. Use the variant required by the surrounding protocol.

See also
Related tools
Related terms