URL编码器/解码器

对URL特殊字符进行编码以便安全传输,或将其解码还原。

What is URL Encoding?

URL encoding, also known as percent-encoding, is a mechanism for encoding information in a Uniform Resource Identifier (URI). It replaces unsafe ASCII characters with a '%' followed by two hexadecimal digits representing the character's byte value. This ensures URLs remain valid and can be transmitted over the internet without issues.

How URL Encoding Works

URL encoding converts characters into a format that can be transmitted over the internet. Safe characters (A-Z, a-z, 0-9, -, _, ., ~) remain unchanged. All other characters are converted to their UTF-8 byte sequence, with each byte represented as %XX where XX is the hexadecimal value.

Cron 解析器
  • Encoding query parameters in URLs
  • Handling special characters in form submissions
  • Creating safe filenames for web downloads
  • Building API request URLs with dynamic parameters
  • Encoding non-ASCII characters in URLs
Examples
输入: Hello World
输出: Hello%20World
输入: name=John&age=30
输出: name%3DJohn%26age%3D30
输入: https://example.com/search?q=test
输出: https%3A%2F%2Fexample.com%2Fsearch%3Fq%3Dtest
Frequently Asked Questions

When should I URL encode?

You should URL encode whenever you're including user input or special characters in URLs, especially in query parameters or path segments.

What's the difference between encodeURI and encodeURIComponent?

encodeURI encodes a complete URI and preserves characters like :, /, ?, and #. encodeURIComponent encodes everything except alphanumeric characters and - _ . ~ making it suitable for encoding query parameter values.