URL 编码器 / 解码器

最后更新:

关于此工具

URL 编码器把 URL 中不安全的字符(空格、&、=、?、/ 与非 ASCII 等)转为 %xx 百分号编码。不编码会破坏 URL 结构。Web 框架通常自动处理,但用字符串拼接 URL 时仍需手动处理。

使用方法

  1. Choose Encode to escape characters, or Decode to recover the original.
  2. Paste the URL or query parameter into the input box.
  3. The output updates as you type — no submit button.
  4. Copy the encoded string into your URL builder, fetch call, or query string.
  5. When in doubt, encode each query parameter individually rather than the whole URL.

常见用例

  • Building a search URL where the query contains spaces or special characters.
  • Generating a redirect URL that passes another URL as a parameter.
  • Constructing a deep link with non-ASCII text (Korean, Japanese, emoji) in the path.
  • Decoding a webhook payload where parameters are URL-encoded twice.
  • Sanity-checking that a third-party callback URL is properly escaped.
  • Encoding a base64 string before placing it in a URL — the + and / are unsafe.

常见问题

Q. What is the difference between encodeURI and encodeURIComponent?

A. encodeURI keeps reserved URL characters (: / ? & =) intact — use it for whole URLs. encodeURIComponent escapes them too — use it for individual parameter values.

Q. Why is a space sometimes encoded as + and other times as %20?

A. + is the legacy x-www-form-urlencoded form (still used in query strings), %20 is the standard percent-encoding used in URL paths. Servers normally accept either in query strings.

Q. Do I need to encode non-ASCII characters?

A. Yes, for compatibility. Modern browsers display Unicode in the URL bar, but the underlying request encodes them as UTF-8 percent-escapes.

Q. Why does decoding produce strange characters?

A. Usually a charset mismatch — the URL was encoded with one encoding (e.g., latin-1) but decoded as another (UTF-8). Fix the source if you can.