Base64 编码器和解码器在线

Base64 编码 — 将二进制数据表示为文本的最常用方法之一。为电子邮件系统开发,它使用 64 个安全字符的集合来编码任何数据。今天 Base64 用于 Web 开发、API、数据存储和许多其他应用程序。

将纯文本、JSON 或任何 UTF-8 数据转换为 Base64 编码。

将 Base64 字符串即时解码为可读文本。

文本输入
将纯文本、JSON 或任何 UTF-8 数据转换为 Base64 编码。
0 字符
0 bytes
0 行数:
~0 size
Base64 输出
您的文本已转换为 Base64
0 字符
0 bytes
0 行数:
~0 size
翻译选项

Base64URL / JWT

Decode URL-safe Base64 tokens (JWTs, API keys, OAuth)

对网页 URL 使用 - 和 _ 而不是 + 和 /

从输出末尾移除 =

为可读性保留空格

在解码前验证 Base64 输入的有效性

尝试示例文本
点击任何示例将其加载到翻译器中

需要转换 JPG、PNG、SVG、WebP 或其他图像文件?请使用我们的图像转 Base64 转换器。

此工具最适合基于文本的 Base64 编码和解码。如需处理图像文件,请使用图像转 Base64 转换器。

打开图像转 Base64 转换器

什么是 Base64 编码?

Base64 是二进制数据的文本表示。它将任何数据 — 文本、文件或符号 — 转换为 64 个安全字符的集合(A-Z, a-z, 0-9, +, /)用于书写,并使用 = 进行填充。

这使其成为以下用途的理想选择:

  • Web 开发:在 HTML、CSS 或 JSON 中嵌入图像或数据
  • API:为 Web 通信编码二进制负载
  • Data transmission: Sending binary safely over text-only protocols
  • Storage: Saving binary content in text-friendly formats
  • 安全:编码凭据和令牌

Base64 编码如何工作

Process Steps
1文本转换为字节(二进制)
2每 3 字节(24 位)组分为 4 个 6 位组
3每 6 位组映射到 64 个 Base64 字符之一
4填充(=)确保输出长度是 4 的倍数
Base64 字母表
A–Z(26 个字符)
a–z(26 个字符)
0–9(10 个字符)
+ 和 /(2 个字符)
= 用于填充

示例:

输入:你好 → 5L2g5aW9
输出:5L2g5aW9 → 你好
URL 安全 Base64

当在 URL 或 API 端点中使用 Base64 数据时,+ 和 / 可能会破坏查询字符串。URL 安全 Base64 将它们替换为:

+ → -
/ → _

此变体移除填充,广泛用于 Web 令牌(JWT)和 REST API。

为什么使用在线 Base64 编码器/解码器

  • 即时:转换在客户端进行,无服务器调用
  • 全球:完全支持 Unicode 和表情符号
  • 私有:您输入的内容不会被发送或存储
  • 开发者友好:与 JSON、XML、URL 和 UTF-8 文本配合使用
  • 准确:严格的验证和填充规则确保准确性
  • 永远免费:无账户或限制

Base64 编码器和解码器在线

免费 Base64 编码器/解码器工具 — 任何想要将文本转换为 Base64 编码或将 Base64 解码为可读文本的人的理想工具。无论您是使用 API 的开发者、学习数据传输的学生,还是只是需要为项目转换数据,我们的转换器使使用 Base64 编码变得简单。

Base64 转换器的主要功能包括:文本和 Base64 之间的即时转换、支持所有国际字符和语言、URL 安全和无填充选项、严格验证和错误处理、实时统计、以及完全免费使用无需注册。

什么是 Base64 编码器/解码器工具?

Base64 编码器/解码器是一个在线工具,让您输入任何文本并立即查看 Base64 版本。您也可以通过将编码的 Base64 文本粘贴到转换器中将其解码回中文文本。

示例:

你好 → 5L2g5aW9
SGVsbG8gV29ybGQ= → Hello World

这使得该工具对开发者、学生和任何从事数据传输和 API 工作的人都有用。

Base64 字母表

Base64 字母表包含 A–Z、a–z、0–9 和 + 和 / 符号。每 3 字节组转换为 4 个 Base64 字符:

A–Z(26 个字符)
a–z(26 个字符)
0–9(10 个字符)
+ 和 /(2 个字符)

= 用于填充

通过练习这些转换,您可以理解 Base64 的工作原理以及如何在项目中使用它。

为什么使用在线 Base64 编码器/解码器工具?

使用在线 Base64 转换器有很多原因:

  • Web 开发:为 Web 应用程序编码图像和数据
  • 数据传输:通过文本协议安全发送二进制数据
  • 数据存储:在基于文本的系统中存储二进制数据
  • API:为 Web 通信编码二进制负载
  • 安全:编码凭据和令牌

这解释了为什么"base64 编码器在线"搜索快速增长 — 人们通过 Web 开发、API 和数据存储重新发现 Base64。

Base64 解码 — 从安全字符到中文

Base64 解码反向工作:不是将文本编码为 Base64,而是读取编码的 Base64 文本并将其转换为纯中文。

例如:

输入:5L2g5aW9
输出:你好!

当您在 API、配置文件或数据库中遇到 Base64 数据并想快速理解它时,此功能很有用。

URL 安全 Base64

当在 URL 或 API 端点中使用 Base64 数据时,+ 和 / 可能会破坏查询字符串。URL 安全 Base64 将它们替换为:

+ → -
/ → _
此变体移除填充,广泛用于 Web 令牌(JWT)和 REST API。

添加 URL 安全选项有助于使 Base64 转换在 Web 应用程序和 API 中更好地工作。

Frequently Asked Questions

How do I encode or decode Base64 with this tool?

To encode: paste or type UTF-8 text (including JSON, URLs, or emoji), keep the direction on encode, adjust URL-safe or padding options if you need them, and run the conversion—the output appears as a Base64 string with live validation. To decode: switch to decode mode, paste the Base64 string, and decode; the tool checks the alphabet and padding, then shows the original text. Everything runs in your browser with UTF-8 end to end.

Is this Base64 encoder and decoder free?

Yes. The tool is free to use with no registration, no paywall, and no limit on how often you encode or decode. Processing stays on your device, so your input is not uploaded or stored on our servers.

Is Base64 the same as encryption?

No. Base64 is encoding, not encryption. Anyone can decode standard Base64 without a secret key. It does not hide meaning—use real cryptography when you need confidentiality, integrity, or authentication.

What is Base64 used for, and why is it used for data in APIs, JSON, and email?

Base64 represents binary data as ASCII text so it can travel safely through systems that only handle text—email (MIME), JSON payloads, URLs, logs, and config files. APIs often use it for small binary blobs or tokens embedded in text. The trade-off is size: encoded data is roughly a third larger than the raw bytes.

What languages and characters does this encoder support—does it work with Unicode and emoji?

Yes. The tool works with UTF-8 text. Any character your browser can represent in UTF-8—including accented letters, symbols, and emoji—can be encoded to Base64 and decoded back when the whole pipeline uses consistent UTF-8.

What is URL-safe Base64?

Standard Base64 uses + and /, which can be problematic in URLs and some query strings. URL-safe Base64 typically replaces + with - and / with _, and may handle padding differently. This tool lets you toggle URL-safe output when you need strings that travel cleanly in web addresses, cookies, or tokens.

Can I encode images with this tool?

This page is optimized for text. To work with images you usually convert them elsewhere (for example to a data URL or another binary workflow), then paste the resulting text here if you want to inspect or practice Base64 on that string—not raw binary upload.

How accurate is Base64 encoding and decoding—is it standards-based?

The implementation follows common Base64 rules (RFC 4648 style): 64-character alphabet, grouping into 24-bit chunks, padding with = when needed, and UTF-8 for text. Validation helps catch malformed input before decoding.

What is "Hello World" in Base64?

For the UTF-8 string "Hello World!", a typical Base64 value is SGVsbG8gV29ybGQh. The exact characters can vary slightly if you change URL-safe or padding options.

What is Base64 padding, and why do strings sometimes end with =?

Base64 turns every 3 bytes into 4 encoded characters. When the input length is not a multiple of 3, the encoder adds padding characters—usually =—so the output length stays a multiple of 4. Decoders use padding to know how many bits in the last group are real data versus fill. Padding is not part of the 64-letter alphabet; it signals how the last block was encoded.

亲自尝试

在线 Base64 编码器/解码器工具专为开发者和爱好者设计。输入您的姓名、最喜欢的名言或秘密消息,看看它在 Base64 中的样子。一键即可:

  • 将文本转换为 Base64
  • 将 Base64 解码回中文
  • 分享您的编码

快速、简单、永远免费。

探索更多文本工具

免费在线工具,用于转换、编码和处理文本

大小写转换

转换文本大小写 — 大写、小写、标题格式等

摩尔斯电码翻译器

将文本转换为摩尔斯电码,反之亦然

二进制翻译器

将文本转换为二进制,反之亦然

ROT13 编码器/解码器

使用 ROT13 密码编码和解码文本

上标生成器

在支持的情况下将文本转换为 Unicode 上标。

下标生成器

将文本转换为支持的Unicode下标

删除线文字生成器

即时生成可复制粘贴的 Unicode 删除线文字

图片转Base64

将图片转换为Base64字符串和数据URI