URL encode (encodeURIComponent) & decode
URL encoding (also called percent-encoding) escapes characters that are reserved or unsafe in URLs — spaces, Chinese, &, =, ?, # and so on — into %XX hex sequences so a URL stays unambiguous as it travels through browsers, servers, and logs.
This tool covers three modes: encode text into a URL-safe string, decode a percent-encoded string back to its original form, and parse a full URL into its components (protocol, host, port, path, query, hash). Everything runs locally in your browser using the native encodeURIComponent / decodeURIComponent / URL APIs.
name=张三&city=北京 朝阳区name%3D%E5%BC%A0%E4%B8%89%26city%3D%E5%8C%97%E4%BA%AC%20%E6%9C%9D%E9%98%B3%E5%8C%BAhello%20world%21%20%F0%9F%91%8Bhello world! 👋https://toolcozy.com/t/url?q=base64&lang=zh#sectionprotocol: https:
host: toolcozy.com
pathname: /t/url
search: ?q=base64&lang=zh
hash: #section
params: q=base64, lang=zhencodeURIComponent escapes everything that isn't a letter, digit, or one of - _ . ! ~ * ' ( ) — making it safe to use as a query value or path segment. encodeURI leaves URL-structural characters (: / ? # & =) alone, so it's only useful when you already have a complete URL and just want to fix unsafe characters. This tool uses encodeURIComponent.
Almost always a character-encoding mismatch. Modern URLs use UTF-8, but some legacy systems percent-encode using GBK or other code pages. If the source wasn't UTF-8, the decoded bytes won't form valid characters — try the original system's encoding instead.
Only encode the value. If you encode an entire URL with encodeURIComponent you'll escape the : and / and the result will no longer be a valid URL. Encode each query parameter value separately, then assemble.
Decode it twice. %2520 → %20 → space. Double encoding usually means a value was encoded once by client code and again by a framework or proxy. Watch for this when chaining systems.
No — the URL constructor needs an absolute URL with protocol. Prepend https:// if you only have a path-and-query string, or use the Decode tab to inspect the raw text instead.