Monu Tools

URL 编码 / 解码

对 URL 和 URL 组件进行百分号编码和解码,UTF-8 安全。

如何使用 URL 编码

  1. 01

    粘贴你的文本或 URL。

  2. 02

    选择编码或解码,以及组件或完整 URL 范围。

  3. 03

    复制结果。

What percent-encoding does

URLs are only allowed to contain a limited set of characters, so anything outside that set, spaces, accented letters, and reserved symbols like & ? / =, has to be escaped. Percent-encoding replaces each such byte with a percent sign and its two-digit hexadecimal value, so a space becomes %20 and an ampersand becomes %26.

This tool encodes text and URLs to percent-encoded form and decodes them back. It is built on the browser's standard encodeURIComponent and encodeURI functions, so the output matches exactly what your own JavaScript would produce, and it is UTF-8 safe for international text.

Encoding and decoding run entirely in your browser, so nothing you paste is sent to a server, which is reassuring when a URL contains tokens or query parameters you would rather not share.

Component mode vs full URL

The scope toggle matters. Component mode (encodeURIComponent) escapes reserved characters like & = ? / and is what you want for a single query-string value or path segment. Full-URL mode (encodeURI) leaves the structural characters intact so a complete URL stays usable.

Common mistakes to avoid

A common mistake is encoding an entire URL with component mode, which escapes the :// and ? and breaks the link. Another is double-encoding, where an already-encoded string is encoded again and %20 turns into %2520. When in doubt, decode first to see the raw value.

The plus-sign quirk in query strings

There is also a historical quirk in query strings: form submissions encode a space as a plus sign, while percent-encoding uses %20. Both are seen in the wild, so decoders generally accept either.

常见问题

组件与完整 URL 有何区别?

“组件”(encodeURIComponent)会转义 & = ? / 等保留字符,适用于查询值。“完整 URL”(encodeURI)会保留 URL 结构。

为什么解码失败?

格式错误的百分号序列(如单独的 %)无法解码。请检查输入,或先重新编码。

来源

嵌入此工具

将此工具添加到你自己的网站。复制下方代码片段即可,它会自动保持最新。

<iframe src="https://monu.tools/embed/zh/url-encoder" width="100%" height="640" style="border:1px solid #e5e5e5;border-radius:12px;max-width:680px" loading="lazy" title="Monu Tools"></iframe>

相关工具