Encoding

Understanding Base64 Encoding and Decoding

August 22, 2026 · 5 min read · By Formattools Team

Base64 encoding is a fundamental technique in web development for converting binary data into a text format that can be safely transmitted over text-based protocols. This guide explains how it works and when to use it.

What is Base64?

Base64 is a binary-to-text encoding scheme that represents binary data in an ASCII string format. It uses 64 characters (A-Z, a-z, 0-9, +, /) plus the = character for padding.

How Base64 Works

  1. Binary data is divided into groups of 3 bytes (24 bits)
  2. Each group is split into 4 chunks of 6 bits
  3. Each 6-bit value is mapped to a Base64 character

Common Use Cases

  • Data URIs: Embedding images in CSS/HTML (data:image/png;base64,...)
  • Email Attachments: MIME encoding for email
  • API Authentication: HTTP Basic Auth headers
  • JSON Web Tokens (JWT): Token encoding
  • Certificate Encoding: PEM files

UTF-8 Support

Base64 works with binary data, so encoding UTF-8 text requires special handling. Our Base64 Encoder automatically handles UTF-8 encoding and decoding correctly.

✨ Try Our Free Base64 Encoder/Decoder

Encode and decode Base64 strings with UTF-8 support.

Open Base64 Tool →