URL 编解码 / URL Encoder / Decoder
功能介绍(中文)
URL 编码(也叫百分号编码)把 URL 中不允许直接出现的字符转换成 % 加两位十六进制的形式。例如空格变成 %20,中文“工具”变成 %E5%B7%A5%E5%85%B7。
本工具提供两种模式:组件模式使用 encodeURIComponent,适合编码查询参数的值,会编码 & = ? / 等分隔符;完整 URL 模式使用 encodeURI,保留协议、路径和查询结构的分隔符,只编码非 ASCII 字符与空格。
空格既可编码为 %20,也可按表单习惯编码为 +,解码时会按同样规则还原。整个编解码过程在浏览器内完成,长链接和含表情符号的内容都能正确处理。
Overview (English)
URL encoding (percent-encoding) converts characters that are not allowed in a URL into a percent sign followed by two hex digits. A space becomes %20; the Chinese word 工具 becomes %E5%B7%A5%E5%85%B7.
This tool has two modes: component mode uses encodeURIComponent for query parameter values and encodes delimiters such as & = ? /; full-URL mode uses encodeURI, preserving structural delimiters while encoding non-ASCII characters and spaces.
Spaces can be encoded as %20 or as + for form-style encoding, and decoding follows the same rule. Everything runs locally in the browser, including long URLs and emoji.
功能特点(中文)
- 组件 / 完整 URL 两种编码范围可选
- 空格支持 %20 与 + 两种风格
- 编码与解码方向明确切换,不靠猜测
- 正确处理中文、表情和多字节字符
Features (English)
- Choose component or full-URL encoding scope
- Spaces as %20 or +
- Explicit encode / decode direction, no guessing
- Correct handling of Chinese, emoji and multibyte characters
常见问题 / FAQ
encodeURI 和 encodeURIComponent 有什么区别?
encodeURI 用于编码完整 URL,会保留 : / ? & = 等具有特殊含义的分隔符;encodeURIComponent 用于编码单独的参数值,会把这些分隔符也编码掉,避免破坏 URL 结构。
What is the difference between encodeURI and encodeURIComponent?
encodeURI encodes a whole URL and keeps delimiters like : / ? & =; encodeURIComponent encodes a single parameter value and escapes those delimiters too, so they cannot break the URL structure.
空格应该编码成 %20 还是 +?
在 URL 路径和一般场景中应使用 %20;在 application/x-www-form-urlencoded 表单查询字符串中,+ 也被广泛接受。本工具两种都支持,可按接口要求选择。
Should spaces be %20 or +?
Use %20 in URL paths and general cases; in application/x-www-form-urlencoded query strings, + is also widely accepted. This tool supports both so you can match your API's requirement.
URL 编码是加密吗?
不是。URL 编码只是字符表示方式的转换,任何人都能解码。它不能保护敏感信息,密码和令牌应通过 HTTPS 传输而不是依赖编码。
Is URL encoding encryption?
No. URL encoding only changes how characters are represented and is trivially reversible. It does not protect sensitive data; use HTTPS for passwords and tokens instead.