Toolypet
开发工具/Base64编码器/解码器

Base64编码器/解码器

将文本编码为Base64或将Base64解码为文本

输入

输出

结果将显示在这里...

选项

Base64 Encoding Guide

Learn how to use Base64 encoding and decoding effectively

What is Base64?

Base64 is a binary-to-text encoding scheme that represents binary data in an ASCII string format. It's commonly used to encode binary data for transmission over text-based protocols like email or to embed binary data in JSON, XML, or HTML.

How to Use This Tool

  1. Enter text or a Base64 string in the input field
  2. Click 'Encode' to convert text to Base64
  3. Click 'Decode' to convert Base64 back to text
  4. Copy the result using the copy button

Pro Tips

  • Base64 encoding increases data size by approximately 33%
  • Use the swap button to quickly reverse encode/decode operations
  • Base64 is not encryption - it's encoding and can be easily decoded

Browser Support

Base64 encoding/decoding is supported in all modern browsers using the built-in btoa() and atob() functions. This tool also handles UTF-8 characters properly.

常见问题

Base64编码有什么用途?

常见用途:1) 在HTML/CSS中嵌入小图片(Data URI),2) 在JSON中传输二进制数据,3) 电子邮件附件编码(MIME),4) 基本HTTP认证,5) 在不支持二进制的系统间传输数据。

Base64会增加多少数据大小?

Base64编码会将数据大小增加约33%。这是因为每3个字节的原始数据变成4个Base64字符。此外可能还有填充字符(=)。因此Base64适合小文件,大文件会显著增加传输量。

Base64和加密有什么区别?

Base64只是编码,不是加密。任何人都可以轻松解码Base64。它的目的是将二进制数据转换为文本格式以便传输,而不是保护数据安全。需要安全性时应使用真正的加密算法(如AES)。

什么是URL安全的Base64?

标准Base64使用+和/字符,这些在URL中有特殊含义。URL安全的Base64用-替代+,用_替代/,并可能省略填充字符=。这样可以直接在URL参数中使用而无需额外编码。

如何在CSS中使用Base64图片?

使用Data URI格式:background: url('data:image/png;base64,编码后的字符串');。适合小图标(几KB以下),可减少HTTP请求。但Base64图片无法被浏览器缓存,大图片会增加CSS文件大小,影响加载速度。