What is Base64 and how to use it?
What is Base64?
Base64 is an encoding scheme that converts binary data into ASCII text representation. It is widely used to transmit binary data through protocols that only handle text, such as HTTP, email, and web APIs.
Common use cases:
- APIs and web services: Send binary data like images or files in JSON
- Email: Attach binary files in text messages
- Storage: Store binary data in text-only databases
- Configuration: Include SSL certificates or keys in config files
- Web development: Include small images directly in CSS or HTML
Practical examples:
Example 1: Encode simple text
Original text:
Hello World!
Base64 result:
SGVsbG8gV29ybGQh
Example 2: Decode Base64
Base64:
VGV4dCB0b29scyBhcmUgYXdlc29tZQ==
Decoded text:
Text tools are awesome
Example 3: Special characters
Text with emojis and special characters:
¡Hola! 🌍 你好 こんにちは
Base64:
wqFIb2xhISDwn4yNIOaPkOS+m+Wkp+Wwjw==
How does it work?
Base64 converts each group of 3 bytes (24 bits) into 4 characters of 6 bits each. The characters used are A-Z, a-z, 0-9, + and /, with = as padding character when needed.
Related keywords:
base64 encoderbase64 decoderencode text to base64decode base64 to textbase64 converter onlinebase64 encoding toolbinary to text converterdata encodingapi data encodingbase64 for web development