URL 编码/解码器

将文本转换为适合 URL 的编码,或解码百分号编码的 URL。

// about

工具介绍

网址中不能直接包含空格或特殊符号。本工具可以将特殊字符转换为安全的网络格式(含 % 符号),或将已编码的网址还原为易读的普通文本。

如何使用

  1. 粘贴您要转换的网址或文本。
  2. 选择“编码(Encode)”或“解码(Decode)”。
  3. 点击“运行”并复制生成的新网址。

人们为何使用此工具

  • 修复因空格、中文或特殊字符导致损坏的网络链接。
  • 解码包含大量 % 符号的复杂网址,还原真实的文字内容。
  • 在浏览器中实时即时转换,方便高效。

常见问题解答 (FAQ)

为什么网址里会有 %20 这样的符号?

因为浏览器会将空格自动替换为 %20,以便服务器正确识别。

什么时候需要进行 URL 编码?

当链接参数中含有中文、空格或问号等特殊字符时都需要进行编码。

这个工具是免费的吗?

是的,完全免费且没有任何次数限制。

指南 · 编码 · 约 4 分钟

Base64 编码详解:原理、用途与常见误解

邮件附件、图片 data URI、JWT 令牌都离不开 Base64。本文说明 Base64 到底做了什么、为什么输出比输入更长,以及什么时候该用、什么时候不该用。

计算机中的一切数据归根结底都是字节。然而很多通道只能安全地传输文本,例如邮件正文、HTTP 头、JSON 文档和 URL。如果把原始图片字节或密文直接塞进这些通道,控制字符和换行可能会破坏数据,中间系统也可能擅自改写内容。

Man   → TWFu
Hi    → SGk=
한    → 7ZWc
안녕  → 7JWI64WV
通过示例讲解 Base64 如何把 3 个字节变成 4 个字符、末尾的 = 是什么意思、Base64URL 有何不同,以及为什么 Base64 不是加密。
阅读指南 →
用 AI 自己做

用 AI 亲手打造这个工具

想要自己的版本?把下面的任务提示词粘贴到 AI 聊天中,或将技能文件保存到 AI 编程助手。其中包含我们开发此工具时整理的功能、边界情况和测试用例。

提示词和技能以英文提供,AI 工具在任何语言环境下都能很好地理解。

AI 任务提示词

直接粘贴到 Claude、ChatGPT、Gemini 等 AI 聊天中即可。

You are an experienced full-stack web developer. Build a web tool called "URL 编码/解码器" that meets the requirements below.

## Goal

Build a tool that percent-encodes and decodes whole URLs or individual query parameter values.

## Core features

- Encode and decode modes
- Component mode (encodeURIComponent) or full-URL mode (encodeURI)
- Option to write spaces as %20 or +
- Break a query string into a key/value table
- Copy result

## Inputs

- A URL or a value to encode
- Mode and space-style option

## Outputs

- Encoded or decoded result
- List of query parameters with decoded values

## Edge cases and handling rules

- Warn when double encoding such as %2520 is detected
- Keep malformed sequences (%G1, trailing %) and show a warning instead of crashing
- Let the user decide whether + means a space
- Handle byte sequences that are not valid UTF-8

## Implementation requirements

- Build it as a single page (HTML, CSS, JavaScript) that runs entirely in the browser, and never send the user's input to a server.
- Make the UI responsive and easy to use on mobile; label every input and keep everything keyboard accessible.
- Add a Copy button for results and show clear, friendly error messages for invalid input.
- Keep the core logic in functions separate from the UI so it can be unit-tested.

## Definition of done (test cases)

- Component-encoding 'a b&c=d' gives 'a%20b%26c%3Dd'
- '안녕' gives '%EC%95%88%EB%85%95'
- Full-URL mode keeps :, /, ? and = in 'https://x.com/a?q=1'

First outline your implementation plan in at most five lines, then write the complete code, and finally explain how to check the test cases above.

技能 (SKILL.md)

在 Claude Code 等 AI 编程助手中保存为 .claude/skills/build-url-codec/SKILL.md,以后开发或修改此工具时可重复使用。

---
name: build-url-codec
description: Use when building or changing a URL 编码/解码器 tool. Build a tool that percent-encodes and decodes whole URLs or individual query parameter values.
---

# Build: URL 编码/解码器

## Goal

Build a tool that percent-encodes and decodes whole URLs or individual query parameter values.

## Workflow

1. Review the required features, inputs and outputs below and ask about anything missing first.
2. Implement the core logic as pure functions separate from the UI.
3. Check the logic against the test cases in the verification list.
4. Build a responsive UI with an input form, a result area and a Copy button.
5. Reproduce each edge case listed under Rules and refine the error messages.

## Core features

- Encode and decode modes
- Component mode (encodeURIComponent) or full-URL mode (encodeURI)
- Option to write spaces as %20 or +
- Break a query string into a key/value table
- Copy result

## Inputs

- A URL or a value to encode
- Mode and space-style option

## Outputs

- Encoded or decoded result
- List of query parameters with decoded values

## Rules

- Warn when double encoding such as %2520 is detected
- Keep malformed sequences (%G1, trailing %) and show a warning instead of crashing
- Let the user decide whether + means a space
- Handle byte sequences that are not valid UTF-8
- Build it as a single page (HTML, CSS, JavaScript) that runs entirely in the browser, and never send the user's input to a server.

## Verification

- [ ] Component-encoding 'a b&c=d' gives 'a%20b%26c%3Dd'
- [ ] '안녕' gives '%EC%95%88%EB%85%95'
- [ ] Full-URL mode keeps :, /, ? and = in 'https://x.com/a?q=1'

交给 AI 时的小技巧

  • 在第一行写明技术栈(如 React、Vue 或纯 HTML),生成的代码会更贴合你的项目。
  • 在接受代码前,请让 AI 运行列出的测试用例并展示结果。
  • 不要把真实密码、客户数据或 API 密钥粘贴到提示词中,请用示例值代替。