About Base64 Encoding
Base64 is a group of binary-to-text encoding schemes that represent binary data in an ASCII string format by translating it into a radix-64 representation.
Common Uses of Base64
- Embedding image data in HTML or CSS files (data URLs)
- Sending binary data in email attachments
- Storing complex data in JSON
- Encoding user credentials in basic authentication
- URL-safe data transfer without special character handling
How Base64 Works
Base64 works by dividing the input data into 3-byte (24-bit) chunks, then splitting each chunk into four 6-bit pieces. Each 6-bit value is used as an index into a table of 64 ASCII characters:
- A-Z (uppercase letters) represent values 0-25
- a-z (lowercase letters) represent values 26-51
- 0-9 (digits) represent values 52-61
- + and / represent values 62 and 63
- = is used for padding when the input length is not a multiple of 3 bytes
URL-Safe Base64
Standard Base64 uses + and / characters which can cause issues in URLs. URL-safe Base64 uses - and _ instead, making it suitable for use in URLs and filenames.
Character Encoding Support
Our Base64 tool properly handles UTF-8 encoding, ensuring that international characters, emojis, and other special characters are correctly encoded and decoded. This is important because JavaScript's built-in btoa/atob functions only support ASCII characters.
Examples
Plain Text | Base64 Encoded |
---|---|
Hello | SGVsbG8= |
Hello, World! | SGVsbG8sIFdvcmxkIQ== |
こんにちは世界 | 44GT44KT44Gr44Gh44Gv5LiW55WM |