Base64 Encoder/Decoder
The Base64 Encoder/Decoder supports Base64 encoding and decoding for both text and files, offering standard Base64 and URL-safe Base64URL formats, suitable for data transmission, file embedding, API authentication, and similar scenarios.
What is Base64
Base64 is an encoding scheme that converts binary data into ASCII strings, using 64 printable characters (A-Z, a-z, 0-9, +, /) to represent data. Since it only uses printable characters, Base64-encoded data can be safely transmitted via text protocols.
Base64 is widely used for:
- Embedding images in HTML and CSS (Data URI)
- Encoding data in URLs and cookies
- Transmitting binary attachments via text protocols like email
- Storing binary data in JSON or XML
- API authentication (such as HTTP Basic Authentication)
Key Features
The tool supports both text and file input, providing standard Base64 and Base64URL encoding formats. All processing is completed locally in the browser, with no data sent to servers, protecting user privacy.
Text encoding and decoding support UTF-8 encoding, capable of processing all Unicode characters including Chinese, Japanese, Korean, and Arabic.
File encoding supports any file type; generated Base64 strings can be directly used for Data URIs or other scenarios requiring Base64 representation.
How to Use
Text Encoding
- Select encoding mode
- Enter text in the input field
- Encoded result displays automatically
- If Base64URL format is needed, check the Base64URL option
- Click the copy button to retrieve results
Text Decoding
- Select decoding mode
- Paste Base64 string in the input field
- If it's Base64URL format, check the Base64URL option
- Decoded result displays automatically
- Click the copy button to retrieve results
File Encoding
- Click file upload area or drag and drop file
- Wait for file reading to complete
- Base64 encoded result displays automatically
- If Base64URL format is needed, check the Base64URL option
- Click the copy button to retrieve results
Base64 vs Base64URL
Standard Base64: Uses A-Z, a-z, 0-9, +, / (64 characters total), with padding character =.
Base64URL: Replaces + with -, replaces / with _, and removes padding character =.
Base64URL is a URL-safe encoding variant, suitable for:
- Passing data in URL parameters
- Including encoded data in filenames
- JWT (JSON Web Token) encoding
- Other scenarios where
+,/,=characters are not allowed
Use Cases
Data URI Image Embedding
Directly embed small images in HTML to reduce HTTP requests:
<img src="data:image/png;base64,iVBORw0KGgo..." />
Embed background images in CSS:
background-image: url(data:image/svg+xml;base64,PHN2Zy...);
API Authentication
HTTP Basic Authentication uses Base64 to encode username and password:
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
JWT Tokens
The Header and Payload parts of JSON Web Tokens use Base64URL encoding.
File Transfer
Transfer file content in JSON APIs:
{
"filename": "document.pdf",
"content": "JVBERi0xLjQKJ..."
}
Email Attachments
MIME protocol uses Base64 encoding for email attachments.
Usage Examples
Text Encoding Example
Input text: Hello, World!
Standard Base64 output: SGVsbG8sIFdvcmxkIQ==
Base64URL output: SGVsbG8sIFdvcmxkIQ
Chinese Text Example
Input text: 你好世界
Standard Base64 output: 5L2g5aW95LiW55WM
File Encoding Example
Upload a small image file to get Base64 encoding similar to:
iVBORw0KGgoAAAANSUhEUgAAAAUA...
Can be used in Data URI:
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..." />
Important Notes
Increased Encoding Size
Base64-encoded data size is approximately 133% of original data (about 33% increase). For large files, encoded size will increase significantly.
Browser Performance
When processing large files, browsers may require considerable time for encoding or decoding; individual files should not exceed 10MB.
Character Encoding
Text encoding uses UTF-8 encoding, supporting all Unicode characters. When decoding, if original data is not UTF-8 encoded text, garbled characters may appear.
Invalid Input
When decoding, if the input Base64 string contains illegal characters or has format errors, an error message will be displayed.
Privacy Protection
All encoding and decoding operations are completed locally in the browser; data is not uploaded to servers.
FAQ
Is Base64 encryption$1
No. Base64 is an encoding method, not an encryption algorithm. Anyone can easily decode Base64 strings; do not use it to protect sensitive information.
Why are there equal signs at the end of encoded strings$2
The equal sign = is a padding character used to pad encoded string length to a multiple of 4. Base64URL format removes these padding characters.
How to choose between Base64 and Base64URL$3
Use Base64URL if encoded results need to be used in URLs, filenames, JWTs, etc. Use standard Base64 for other situations.
Why are there garbled characters after decoding$4
The original data may not be UTF-8 encoded text, or the Base64 string was truncated or modified. Ensure complete and correct Base64 string input.
How large can encoded files be$5
File size that browsers can handle depends on available memory; recommended not to exceed 10MB. For very large files, use specialized file transfer tools.



