URL 在线编码
将文本编码为安全的 URL 格式。在 encodeURIComponent 和 encodeURI 模式之间切换,输入时实时编码。
URL 编码(百分号编码)将 URL 中不允许的字符转换为百分号编码格式(%XX)。此免费在线 URL 编码器同时支持 encodeURIComponent 和 encodeURI,输入时实时编码。
encodeURI 与 encodeURIComponent 对比
JavaScript 提供两个 URL 编码函数,它们编码的字符不同。根据使用场景选择正确的函数。
encodeURI()
编码完整 URL(保持结构:://?#&=)
encodeURIComponent()
编码 URL 组件(查询参数值、路径片段)
| 字符 | encodeURI | encodeURIComponent |
|---|---|---|
| space | %20(编码) | %20(编码) |
| ! | !(不编码) | !(不编码) |
| # | #(不编码) | %23(编码) |
| $ | $(不编码) | %24(编码) |
| & | &(不编码) | %26(编码) |
| + | +(不编码) | %2B(编码) |
| , | ,(不编码) | %2C(编码) |
| / | /(不编码) | %2F(编码) |
| : | :(不编码) | %3A(编码) |
| ; | ;(不编码) | %3B(编码) |
| = | =(不编码) | %3D(编码) |
| ? | ?(不编码) | %3F(编码) |
| @ | @(不编码) | %40(编码) |
FAQ
评价此工具
3.7 / 5 · 147 人评价
Recommended
CloudflareFree CDN & DDoS protection保持更新
获取每周开发技巧和新工具通知。
无垃圾邮件,随时退订。
Enjoy these free tools?
☕Buy Me a Coffee