- What is URL encoding and when should I use it?
- URL encoding (percent-encoding) converts special characters in URLs to a format safe for transmission. Use it when: passing data in query strings, submitting form data, handling non-ASCII characters (like Chinese, Japanese), including special characters (spaces, symbols) in URLs, and constructing API requests with parameters containing special characters.
- What is the difference between encodeURI() and encodeURIComponent()?
- encodeURI() encodes a complete URL but preserves characters like :, /, ?, #, & that have special meaning in URLs. encodeURIComponent() encodes individual URL components (like query parameter values) and encodes all special characters. Use encodeURIComponent() for query parameters and encodeURI() for full URLs.
- How are Unicode characters encoded?
- Unicode characters are first converted to UTF-8 bytes, then each byte is percent-encoded as %XX. For example, "你好" becomes %E4%BD%A0%E5%A5%BD. This ensures international characters are properly transmitted in URLs.
- Can I decode URL-encoded strings?
- Yes, this tool supports both encoding and decoding. Paste a URL-encoded string (like %20 for space) and click "Decode" to convert it back to the original text. This is useful for debugging URLs and understanding encoded content.
- Are there characters that should never be encoded?
- Unreserved characters (A-Z, a-z, 0-9, -, _, ., ~) are never encoded. Reserved characters (!, *, ', (, ), ;, :, @, &, =, +, $, /, ?, #) are encoded when used as data values but preserved when they have special meaning in URL structure.