Base64 Encode / Decode

Use the online tools below to Base64-encode or decode text, images, and files. To ensure data safety, the encoding and decoding are performed within the browser without being sent across the internet.

Text to encode or decode:
Character:

Base64 Encode / Decode an Image or File

Use the tool below to Base64-encode or decode images and files. For text output, the result will be shown in the text area with options to copy or download. For image and binary output, the generated file will be downloaded directly. For large files, the encoding and decoding may take some time.

I want to:


Base64 encoding and decoding is a method used to convert binary data to and from text format. Some computer systems—especially legacy systems—and certain transmission or storage formats are designed to handle text more reliably than raw binary data. Base64 encoding allows binary information, such as images, files, or other data, to be represented using a set of 64 printable ASCII characters, making it suitable for use in these systems and environments.

The Base64 character set includes uppercase letters A–Z, lowercase letters a–z, digits 0–9, and two additional characters, usually + and /. The symbol = is sometimes used as padding at the end of the encoded output to ensure that the encoded string has the proper length. The following table shows the Base64 characters and their corresponding numeric values based on RFC 4648.

0: A8: I16: Q24: Y32: g40: o48: w 56: 4
1: B9: J17: R25: Z33: h41: p49: x 57: 5
2: C10: K18: S26: a34: i42: q50: y 58: 6
3: D11: L19: T27: b35: j43: r51: z 59: 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: /

Modern computers are byte-based (8 bits per byte), while Base64 encoding represents data using 6-bit values mapped to 64 characters. As a result, Base64-encoded data is typically about 4/3 (≈1.33) times the size of the original data.

As an example, the simple text 'Dog' can be encoded in Base64 as 'RG9n,' as shown in the table below.

Input letterDog
8-bit decimal value68111103
Bits010001000110111101100111
6-bit decimal value1766139
Encoded Base64 letterRG9n

In the example above, the three ASCII characters in 'Dog' have a total of 3 × 8 = 24 bits. This can be divided evenly into four 6-bit blocks. In many cases, there will be 2 or 4 bits remaining at the end. In such situations, one or two '=' padding characters are added to the end of the encoded result to represent the missing bits. For example, 'Do' can be encoded in Base64 as 'RG8=,' as shown below.

Input letterDo 
8-bit decimal value68111
Bits010001000110111100Padding
6-bit decimal value17660
Encoded Base64 letterRG8=

Similarly, 'Dogs' can be encoded in Base64 as 'RG9ncw==,' as shown below.

Input letterDogs 
8-bit decimal value68111103115
Bits010001000110111101100111011100110000Padding
6-bit decimal value17661392848
Encoded Base64 letterRG9ncw==

Base64 encoding and decoding are widely used in data transmission, web development, and file processing. The following are two examples of many uses:

E-mail attachments: Originally, SMTP was designed to transport only 7-bit ASCII characters. Encoding binary data using Base64 allows older SMTP servers to correctly transmit attachments.

Embedding binary data in text files: Text-based formats are widely used in computer systems, especially for transmitting data over the internet. Base64 enables the embedding of binary data in these text files. For example, binary data can be Base64-encoded and included in JSON or XML files. Images or PDF files can also be Base64-encoded and embedded in HTML or CSS. The following is the embeddable HTML for the PNG image of .

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAD0AAAASCAMAAADfRiY4AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAABhQTFRFARgJAQoEA30rAiQNAkgZAmMiAQEBA4YuPW1sXQAAAQxJREFUeNrMk8t2wzAIRGF46P//uDPISW0nJ1100bKxjLhiBtm2fhP21zRyAj/UnkpQ33S1RYR7fWJh/iyBxZmuSX20EYYnFf1Cr2ytqUICkXxOHya4jdZb5S58Q4dpGTknh2cKKFciuYE6fFfz5DMdnEgYz0g7RIhUzWjNRnbY9g03XGlNzTy3wwrSfFMjCi5GbyEzmnCseOe76NK6nXTxSb/VO0hjV6bOMyvcaKml3cKMjxOyrsfWOnJNYTvqRmusM1kqxzFnzHSRwNRQgYzcestcGg0Zb5UXspbPopb8IihbQ+UFHJd/8a1wtSPZJqpcbtVWWxIiyYFX+vJB1uN7rcI1g8I/+kO/BBgAnGwZHreSkaQAAAAASUVORK5CYII=" />

There are numerous online and offline tools, as well as built-in commands in operating systems, to convert data to and from Base64 format. Our tools above provide a convenient way to perform these conversions directly in the browser without sending data across the internet.

Financial Fitness & Health Math Other