Understanding Base64 Encoding and Decoding
What is Base64?
Base64 is a binary-to-text encoding scheme that represents binary data using 64 ASCII characters. It converts binary data into a format that can be safely transmitted over text-based protocols.
Why Use Base64?
Base64 is commonly used for:
- Embedding binary data (images) in HTML/CSS
- Encoding data in JWT tokens
- Transmitting binary data over email (MIME)
- Storing binary data in JSON
- HTTP Basic Authentication headers
How Base64 Works
Base64 takes groups of 3 bytes (24 bits) and encodes them as 4 ASCII characters from a 64-character alphabet (A-Z, a-z, 0-9, +, /). The = sign is used for padding. If bits and bytes are new territory, our guide on how to read binary builds that foundation.
Base64 vs Encryption
IMPORTANT: Base64 is NOT encryption! It is easily reversible and provides no security. Never use it to secure sensitive data. For the full explanation of why โ and what to reach for instead โ see is Base64 encryption?
Using Base64 in JavaScript
Encoding: btoa('Hello, World!') Decoding: atob('SGVsbG8sIFdvcmxkIQ==')
Try Our Base64 Tools
- Base64 Encoder โ Encode text or files
- Base64 Decoder โ Decode Base64 strings
Weighing Base64 against other ways to write bytes as text? Base64 vs hex vs binary covers when each one fits.
Lauren Prescott writes for CodeUtilityKit, where the team builds free, privacy-first developer tools that run entirely in your browser. Every guide is written and reviewed by developers who use these tools daily.