F

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

  1. 将需要处理的文本或参数值粘贴到输入框。Paste the text or parameter value into the input box.
  2. 点击「编码」将特殊字符转换为 %XX 形式;点击「解码」还原。Click "Encode" to turn special characters into %XX form, or "Decode" to restore them.
  3. 拼接 URL 时,只对参数值编码,不要对整条 URL 的结构字符(?、&、=)编码。When building URLs, encode only parameter values — not the structural characters (?, &, =) of the URL itself.
  4. 复制结果粘贴到代码或浏览器地址栏验证。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

相关工具Related Tools