URL 编解码器

URL Encoder / Decoder

URL 编码/解码 · encodeURI vs encodeURIComponent 对比

Encode & decode URLs · Compare encodeURI vs encodeURIComponent

输入 URL 或文本Input URL or Text
encodeURI
encodeURIComponent
decodeURI
decodeURIComponent
💡 encodeURI vs encodeURIComponent 区别💡 encodeURI vs encodeURIComponent
字符CharencodeURIencodeURIComponent
:不编码 ✓%3A
/不编码 ✓%2F
?不编码 ✓%3F
#不编码 ✓%23
&不编码 ✓%26
=不编码 ✓%3D
空格%20%20
中文%E4%B8%AD...%E4%B8%AD...

规则:编码完整 URL → 用 encodeURI;编码查询参数值 → 用 encodeURIComponentRule: Encoding a full URL → use encodeURI; Encoding a query parameter value → use encodeURIComponent

Frequently Asked Questions 常见问题

What is URL encoding?什么是 URL 编码?

URL encoding converts special characters into percent-encoded format (e.g., space → %20). This ensures URLs remain valid when transmitted over the internet.URL 编码将特殊字符转换为百分号编码格式(如空格 → %20),确保 URL 在网络传输中保持有效。

What is the difference between encodeURI and encodeURIComponent?encodeURI 和 encodeURIComponent 有什么区别?

encodeURI preserves URL structural characters (:/?#=+&@) while encodeURIComponent encodes everything. Use encodeURI for full URLs and encodeURIComponent for individual query parameter values.encodeURI 保留 URL 结构字符(:/?#=+&@),encodeURIComponent 编码所有内容。完整 URL 用 encodeURI,查询参数值用 encodeURIComponent。

When should I use URL encoding?什么时候需要 URL 编码?

Whenever you include special characters (spaces, Unicode, &, =) in a URL query string or path segment. This prevents broken links and security issues.当 URL 查询字符串或路径段中包含特殊字符(空格、Unicode、&、=)时必须编码,防止链接失效和安全问题。

← Back to all tools← 返回所有工具