数据安全提示: 所有文本数据均在您的浏览器本地处理,不会上传到服务器。
URL编码/解码工具
JavaScript 原生函数
当前操作:encodeURI 编码
输入文本/URL
字符数: 0
转换结果
转换结果将显示在这里...
等待输入...
长度: 0
使用示例
"hello world" → encodeURI
hello%20world
"hello world" → encodeURIComponent
hello%20world
完整URL编码 (encodeURI)
保留://?#,编码中文
查询参数编码
编码等号和&
"hello%20world" → decodeURI
hello world
批量编码比较
同时查看两种编码
URL编码算法原理
URL编码(百分号编码)将特殊字符转换为 % 后跟两位十六进制数。JavaScript 提供两种编码函数:
encodeURI
保留 URI 保留字符(:/?#[]@),适用于编码整个 URL。
encodeURIComponent
编码所有非字母数字字符,适用于编码查询参数值。
| 字符 | encodeURI | encodeURIComponent |
|---|---|---|
| :/?#[]@ | 不编码 | 编码 |
| 空格 | %20 | %20 |
| 中文 | 编码 | 编码 |