Base64 编解码

在浏览器中 Base64 编码与解码

Input

Loading editor...

Output

Loading editor...

Encode and decode Base64 without trusting an online server

Base64 shows up everywhere — JWT payloads, image data URIs, email attachments, API request bodies. Encoding and decoding it in your browser keeps the data on your machine, which matters when the value is a token, a secret, or anything else you'd rather not paste into a remote service.

Use the tool when you need to

Decode a Base64-encoded value from a header

Inspect Authorization headers, encoded query parameters, or other Base64 strings safely in the browser.

Encode binary data for an API

Convert a small image or file into a Base64 string for inclusion in a JSON request body.

Flip between Base64 and Base64URL

Switch encoding variants when working with JWTs and URL-safe payloads.

How to encode or decode Base64 quickly

  1. 1

    Paste the input into the text area.

  2. 2

    Click Encode or Decode based on the direction you need.

  3. 3

    Copy the result, or download it as a file when working with binary data.

Common Base64 workflows

Inspect an Authorization header

Decode a Basic auth header to see the raw username and password format being sent.

Embed a small asset in JSON

Encode a tiny image as a data URI and embed it directly in an API request body.

Round-trip token payloads

Decode a JWT segment, edit it, and re-encode it for testing — without server-side help.

相关工具

常见问题

Base64 会把二进制数据编码成 ASCII 文本,使用 64 个可打印字符(A-Z、a-z、0-9、+、/)。常用于在 JSON、XML、HTML、邮件等纯文本格式里嵌入二进制内容。编码后体积通常会比原始数据大约增加 33%。

把文本粘贴到输入框,点击 Encode。工具会先按 UTF-8 将字符转成字节,再转换为 Base64。点击 Copy 可复制结果。

常见场景:在 CSS/HTML 里内嵌小图片(data URI)、在 JSON API 中传输二进制数据、上传时对文件内容做编码、邮件附件(MIME)、在只支持文本的数据库中存储二进制内容。

标准 Base64 使用 + 和 /,放到 URL 里往往需要转义。Base64URL 用 - 和 _ 替换它们,并且通常去掉填充符号(=)。JWT 常用 Base64URL,因为 token 经常会出现在 URL 中。