Base64 编码/解码器
Base64 编解码工具。可将文本数据编码为 Base64,或将 Base64 数据解码为文本。最多处理 5,120 个字符。
Data to encode
结果
Read Only
使用方法
关于此工具
这个Base64编码解码器可以让您在同一个页面内将文本编码为Base64,或将Base64解码回文本。适用于令牌、配置值、数据URI,以及当API或文件需要ASCII安全内容时的快速调试。 Base64是编码,而非加密。任何人都可以解码其输出,因此不要将其当作隐藏机密信息的方式。根据需要在编码和解码之间切换,然后将结果复制到您的编辑器、终端或工单中。 转换过程在您的浏览器中运行。该工具免费,无需账号。当您需要从Cursor、Claude或自己的脚本中循环执行相同的编码/解码步骤时,可以使用Thousand API MCP实现自动化。
使用方法
切换编码/解码,在文本框中输入或粘贴。结果实时显示,可复制。
选项
方向:在编码(文本→Base64)和解码(Base64→文本)之间切换。
使用场景
• 生成 Data URI • 混淆字符串(注:Base64 非加密) • Basic 认证 • 小型二进制转文本
代码示例
PHP
Read Only
1// Encode (UTF-8 is stored as bytes; no extra conversion needed)
2$encoded = base64_encode('Hello, 世界');
3
4// Decode; true = strict mode (reject invalid characters)
5$decoded = base64_decode($encoded, true);
6
7// If the source is not UTF-8, convert first
8$utf8 = mb_convert_encoding($text, 'UTF-8', 'SJIS');
9$encoded = base64_encode($utf8);Laravel
Read Only
1use Illuminate\Support\Facades\Storage;
2
3// Embed an image as a data URI in a JSON response
4$bytes = Storage::disk('local')->get('logo.png');
5$base64 = base64_encode($bytes);
6
7return response()->json([
8 'image' => 'data:image/png;base64,' . $base64,
9]);Python
Read Only
1import base64
2
3encoded = base64.b64encode('Hello, 世界'.encode('utf-8')).decode('ascii')
4decoded = base64.b64decode(encoded).decode('utf-8')
5
6# URL-safe variant (uses - and _ instead of + and /)
7urlsafe = base64.urlsafe_b64encode(b'data').decode('ascii')Node.js
Read Only
1// Encode UTF-8 text
2const encoded = Buffer.from('Hello, 世界', 'utf8').toString('base64');
3
4// Decode back to UTF-8
5const decoded = Buffer.from(encoded, 'base64').toString('utf8');隐私与数据处理
编码和解码在浏览器内完成,不会将输入发送到服务器。
常见问题
- Q: 什么是Base64?
- A: 一种使用64个字符将二进制数据表示为ASCII文本的编码方式,常用于令牌、数据URI和配置值中。
- Q: Base64是加密吗?
- A: 不是。它是编码,而非加密。任何人都可以解码。
- Q: 我可以在这里同时编码和解码吗?
- A: 可以。在同一个工具中切换编码和解码模式即可。
- Q: 处理过程是在本地进行的吗?
- A: 是的。转换在您的浏览器中运行。
