Skip to content
Calculator.hair

Base64 Encode / Decode

Encode or decode

Press Calculate to see the results.

Base64 Encode / Decode an Image or File

Paste Base64 data, with or without a data: URI prefix, to see what kind of file it contains, its size and the first bytes. To encode a file you have, use your operating system's base64 command (base64 file on macOS and Linux, certutil -encode on Windows) and paste the result here to check it.

Press Calculate to see the results.

Paste text to encode it as Base64, or paste Base64 to decode it back to text. This Base64 encode decode tool runs in your browser and supports UTF-8, UTF-16 and many legacy character sets.

Base64 is a way of writing any binary data, whether text in some character encoding, an image, a PDF or an encryption key, using only 64 characters that are safe almost everywhere: the capital letters A to Z, the lowercase letters a to z, the digits 0 to 9, and the plus and slash signs, with the equals sign used for padding. It was developed for email, whose original standards could carry only plain 7-bit text, and is defined today in RFC 4648.

Base64 is used for email attachments (MIME), for embedding small images and fonts directly in HTML and CSS through data: URIs, for binary values in JSON and XML, for the header and payload of JSON Web Tokens, and for HTTP Basic authentication headers. It is an encoding, not encryption: anyone can decode it, so it never protects secrets on its own.

The price of that safety is size. Every three bytes of input become four characters of output, so Base64 is about 33% larger than the original data, plus line breaks if the text is wrapped at 76 characters as MIME requires.

0–78–1516–2324–3132–3940–4748–5556–63
0: A8: I16: Q24: Y32: g40: o48: w56: 4
1: B9: J17: R25: Z33: h41: p49: x57: 5
2: C10: K18: S26: a34: i42: q50: y58: 6
3: D11: L19: T27: b35: j43: r51: z59: 7
4: E12: M20: U28: c36: k44: s52: 060: 8
5: F13: N21: V29: d37: l45: t53: 161: 9
6: G14: O22: W30: e38: m46: u54: 262: +
7: H15: P23: X31: f39: n47: v55: 363: /

Encoding works on groups of three bytes, which is 24 bits. Those 24 bits are split into four groups of 6 bits, and each 6-bit value, from 0 to 63, is replaced by the character at that position in the alphabet above. Take the word Dog in ASCII or UTF-8: D, o and g are bytes 68, 111 and 103, or 01000100 01101111 01100111 in binary. Regrouped into six-bit chunks, 010001 000110 111101 100111, they are 17, 6, 61 and 39, which are the letters R, G, 9 and n. So Dog encodes to RG9n.

StepDog
CharactersD · o · g
Byte values68 · 111 · 103
Bits01000100 01101111 01100111
Regrouped into 6 bits010001 000110 111101 100111
6-bit values17 · 6 · 61 · 39
Base64 charactersR · G · 9 · n

When the input length is not a multiple of three, the last group is padded with zero bits and the output is completed with one or two equals signs so that its length stays a multiple of four. Do (two bytes, 16 bits) becomes RG8=, and Dogs (four bytes) becomes RG9ncw==. Some variants, such as the URL-safe alphabet used in web tokens, replace + and / with - and _ and drop the padding.

Because Base64 encodes bytes, the result for text depends on the character encoding chosen first. ASCII letters are the same in nearly every encoding, but accented letters, Cyrillic, Chinese or emoji become different byte sequences in UTF-8, UTF-16 or a legacy code page, and so produce different Base64. When decoding, choose the same character set that was used to encode, or the text will come out garbled. UTF-8 is the right choice for almost all modern data.

TextBytes (UTF-8)Base64
Dog44 6f 67RG9n
Do44 6fRG8=
Dogs44 6f 67 73RG9ncw==
éc3 a9w6k=

Frequently asked questions

Is Base64 encryption?

No. Base64 is a reversible encoding that anyone can decode. Use real encryption, such as AES, to protect data.

Why does Base64 output end with = or ==?

The equals signs are padding. They appear when the input length is not a multiple of three bytes, so the output length stays a multiple of four.

How much bigger is Base64 than the original?

About 33% larger, because every 3 bytes become 4 characters.

Is my text sent to a server?

No. Encoding and decoding happen entirely in your browser.

Updated by Calculator.hair. How we build and check our calculators