Free2BoxFree2Box

Base64 编解码工具

快速将文字编码为 Base64 格式,或将 Base64 解码回原始文字。

原始文字
输入要编码的文字
Base64 结果
编码后的 Base64 字符串
什么是 Base64?

Base64 是一种用于将二进制数据编码为 ASCII 字符串的编码方式。它常用于:

  • 在 URL 或 Email 中传输二进制数据
  • 在 JSON 或 XML 中嵌入图片数据
  • 存储密码或敏感信息(虽然不是加密)
  • 在 HTTP 基本认证中编码用户名和密码

⚠️ 注意:Base64 是编码方式,不是加密方式。请勿用于保护敏感信息。

使用方法

1

粘贴或输入内容

在输入区域输入您的文字、代码或数据。

2

选择选项

选取要应用的转换方式或格式。

3

复制结果

一键将输出结果复制到剪贴板。

为什么使用此工具

100% 免费

没有隐藏费用,没有付费等级——所有功能完全免费。

无需安装

完全在浏览器中运行。无需下载或安装任何软件。

隐私且安全

您的数据永远不会离开您的设备。不会上传至任何服务器。

支持移动设备

完全响应式设计——在手机、平板或桌面电脑上均可使用。

Base64 Encoding and Decoding Explained

Key Takeaways

  • Base64 converts binary data into ASCII text, making it safe to transmit through text-only channels like email and JSON.
  • Base64 is an encoding scheme, not encryption — it provides no security and can be decoded by anyone.
  • All encoding and decoding happens in your browser — your data stays on your device.

Base64 encoding is one of the most fundamental data transformation techniques in web development. It represents binary data using 64 ASCII characters (A-Z, a-z, 0-9, +, /), enabling safe transmission of files, images, and binary content through text-based protocols. Understanding Base64 is essential for working with APIs, email systems, and data URIs.

Base64 encoding increases data size by approximately 33% compared to the original binary.

Size Overhead

Key Concepts

1

How Base64 Works

Base64 takes every 3 bytes (24 bits) of input and splits them into four 6-bit groups, mapping each to one of 64 printable ASCII characters. Padding with '=' is added when input length is not a multiple of 3.

2

Data URI Embedding

Base64-encoded images can be embedded directly in HTML and CSS using data URIs (data:image/png;base64,...), eliminating extra HTTP requests for small assets.

3

Email Attachments (MIME)

Email protocols like SMTP are text-based. Base64 encoding via MIME allows binary attachments like images and documents to travel safely through email systems.

4

Base64url Variant

The URL-safe variant replaces '+' with '-' and '/' with '_' to avoid conflicts in URLs and filenames. This variant is used extensively in JWTs and OAuth tokens.

Pro Tips

Never use Base64 for security — it is trivially reversible. Use proper encryption (AES, RSA) for sensitive data.

Avoid Base64-encoding large images inline; the 33% size increase negates the benefit of saving an HTTP request.

Use Base64url (RFC 4648 §5) instead of standard Base64 when the output will appear in URLs or filenames.

Most modern browsers support btoa() and atob() natively, but they only handle Latin-1 characters — use TextEncoder for Unicode.

All Base64 encoding and decoding is performed entirely in your browser. Your data is never transmitted to any external server, making this tool safe for sensitive content.

常见问题