Base64 is a method for representing binary data using 64 printable characters. It is primarily used to transmit binary data (such as images, audio, encryption keys) over media that only support text content (like email, HTML, JSON, XML).
The 64 core characters used by Base64 include:
A-Z (26)a-z (26)0-9 (10)+ and / (2)= is used as padding at the end.The core logic of Base64 is to convert three 8-bit bytes (24 bits) into four 6-bit bytes (24 bits).
= for padding at the end. This is why many Base64 strings end with one or two = characters.Note: After Base64 encoding, the data size typically increases by about 33% compared to the original data.
| Feature Type | Description |
|---|---|
| Text Base64 Encode/Decode | Input text for instant conversion |
| Image Base64 Encode/Decode | Supports PNG/JPEG/GIF/WebP |
| Audio/Video Base64 Encode | Supports MP3/MP4/WAV, etc. |
| Any File Base64 Encode | PDF, ZIP, documents, etc. |
| Base64 to File (Blob) | Convert Base64 back to a downloadable file |
| Multi-Platform Support | Works on both computers and mobile devices |
| Frontend-Only Operation | Files are NOT uploaded to any server |
Such as PDF, ZIP, DOCX, EXE, etc.
Steps:
Suitable for:
In frontend development, to reduce the number of HTTP requests, developers often convert small icons directly into Base64 strings and embed them in HTML or CSS.
background-image: url("data:image/png;base64,iVBORw0KGgoAAA...");Early email systems were primarily based on ASCII and could not directly transmit binary images or attachments. Base64 converts attachments into plain text format, ensuring stable transmission between different mail servers.
Standard Base64 contains + and /, which get escaped during URL transmission. The tool provided on this site supports URL Safe mode, replacing these symbols with - and _, allowing them to be used directly as URL parameters without secondary encoding.
When calling Web API interfaces, if non-text data (such as RSA public keys, binary file streams) needs to be transmitted, it is usually first converted into a Base64 string and nested within a JSON object.
Q: Is Base64 an encryption method?
A: No. Base64 is only an encoding method. Anyone can restore the original data using a Base64 decoding tool. Its purpose is "facilitating transmission," not "data protection." If encryption is needed, please use the [AES] or [RSA] encryption tools provided on this site.
Q: Why does data become larger after Base64 encoding?
A: Because Base64 uses 4 characters to represent the original 3 bytes of data. Every 3 bytes of original data are encoded into 4 Base64 characters, so the size increases by a fixed ratio of about 1/3.
Q: What causes the "Invalid character" error during decoding?
A: This is usually because the string to be decoded contains characters outside the Base64 character set (such as spaces, special emojis, or incorrect line breaks). Please ensure the copied string is complete and free of interfering characters.
For Base fundamentals and encoding principles, see: Base64 Quick Start: Principles, Scenarios, Format, and Code Examples.