URL 编解码URL Encoder/Decoder
URL编码与解码,处理特殊字符URL encode and decode, handle special characters.
编码结果
—
解码结果
—
关于 URL 编解码About URL Encoder/Decoder
URL 中只能直接出现有限的字符集合,中文、空格以及 &、=、? 等特殊字符必须经过编码才能安全传输。本工具提供 URL 编码与解码,帮助你正确拼接查询参数、还原链接原文,避免“链接发出去就坏了”的问题。URLs allow only a limited character set; Chinese, spaces and special characters like & , = and ? must be encoded to travel safely. This tool encodes and decodes URLs, helping you build query parameters correctly and restore original links.
使用方法How to Use
- 将需要处理的文本或参数值粘贴到输入框。Paste the text or parameter value into the input box.
- 点击「编码」将特殊字符转换为 %XX 形式;点击「解码」还原。Click "Encode" to turn special characters into %XX form, or "Decode" to restore them.
- 拼接 URL 时,只对参数值编码,不要对整条 URL 的结构字符(?、&、=)编码。When building URLs, encode only parameter values — not the structural characters (?, &, =) of the URL itself.
- 复制结果粘贴到代码或浏览器地址栏验证。Copy the result into your code or browser address bar to verify.
常见问题FAQ
encodeURIComponent 和 encodeURI 的区别?What is the difference between encodeURIComponent and encodeURI?
前者会编码 &、=、? 等所有保留字符,适合编码单个参数值;后者保留 URL 结构字符,适合编码整条 URL。混用是参数丢失的常见原因。The former encodes all reserved characters (&, =, ? …) and suits single parameter values; the latter preserves URL structure and suits whole URLs. Mixing them up is a common cause of lost parameters.
空格为什么有时是 %20 有时是 +?Why is a space sometimes %20 and sometimes +?
在查询字符串的表单规范(application/x-www-form-urlencoded)中空格写作 +,在通用百分号编码中是 %20;两者解码后都是空格。In form-style query strings (application/x-www-form-urlencoded) a space is written as +, while generic percent-encoding uses %20; both decode to a space.
中文编码后特别长正常吗?Is it normal for encoded Chinese to be very long?
正常。UTF-8 下一个中文占 3 个字节,每个字节编码为 %XX,所以一个汉字会变成 9 个字符。Yes. In UTF-8 one Chinese character takes 3 bytes, and each byte becomes %XX, so a single character turns into 9 characters.
本工具和 encodeURIComponent 有什么区别?What is the difference between this tool and encodeURIComponent?
本工具提供与 encodeURIComponent 一致的百分号编码,并额外支持全 URL 编码、表单编码(空格转 +)两种模式,便于对齐不同服务端框架。It applies percent-encoding consistent with encodeURIComponent, plus two extra modes — full-URL encoding and form encoding (space becomes +) — for aligning with different server frameworks.
如何避免双重编码?How do I avoid double encoding?
编码前先确认原始值没有被编码过;若看到 %25 开头,说明 % 本身被编码了一次。可把可疑字符串粘贴到本工具反复解码验证。Confirm the raw value was not already encoded; if it starts with %25, the % itself was encoded once. Paste suspicious strings into this tool and decode repeatedly to verify.
相关阅读Related Reading
HTML 实体编解码: 与空格的区别,以及 XSS 防护中的转义边界HTML Entity Encoding: Why Is Not a Space, and Escaping Boundaries in XSS Defense
` ` 看起来就是个空格,但 `trim()` 去不掉、`split(' ')` 切不开,因为它根本不是空格。本文从实体编码的原理讲起,结合 XSS 转义边界的真实案例,说清什么时候该转义、转义哪些字符。` ` looks like a space, but `trim()` won't remove it and `split(' ')` won't split on it — because it is not a space at all. This article starts from how entity encoding works, then uses real XSS escaping boundary cases to explain when to escape and which characters to escape.
Unicode 与中文:为什么 \u4e2d 是"中",以及 Emoji 代理对的长度坑Unicode and Chinese: Why \u4e2d Means "中", and the Emoji Surrogate Pair Length Trap
从 `\u4e2d` 到"中"只差一次码点查表,但 Emoji 一出现,`string.length` 就开始撒谎。本文讲清码点、编码单元与代理对的关系,以及我在前后端联调中踩过的三个真实坑From `\u4e2d` to "中" is just one code-point lookup, but the moment Emoji enters the picture, `string.length` starts lying. This article explains code points, code units and surrogate pairs, plus three real bugs I hit during frontend-backend integration.
相关工具Related Tools
Base64 编解码Base64 Encoder/Decoder
Base64编码与解码,支持文本和文件Base64 encode and decode, supports text and files.
Unicode 中文互转Unicode Converter
Unicode编码与中文字符互相转换Convert between Unicode escapes and Chinese characters.
HTML 实体编解码HTML Entity Encoder
HTML实体编码与解码HTML entity encoding and decoding.
进制转换Number Base Converter
二进制、八进制、十进制、十六进制互转Convert between binary, octal, decimal and hexadecimal.