URL Encoder/Decoder
An online tool to encode and decode URL strings.
How to Use the URL Encoder/Decoder
This tool lets you easily encode and decode text and URLs. The "Encode" tab converts characters into URL-safe format (percent encoding), and the "Decode" tab restores encoded URL strings back to the original text. You can choose between "encodeURIComponent" and "encodeURI". encodeURIComponent is used for encoding query parameter values, while encodeURI is used for encoding entire URLs. encodeURIComponent is recommended for most use cases.
About URL Encoding
URL encoding (percent encoding) is a method of representing characters that cannot be used in URLs as a % followed by hexadecimal digits. It is defined in RFC 3986 and is widely used for data transmission on the web. JavaScript has two encoding functions: encodeURIComponent encodes all characters except alphanumeric and -_.!~*'(), and is used for URL query parameter values. encodeURI does not encode URL-valid characters (:, /, ?, #, &, =, etc.) and is used for entire URLs. When handling non-ASCII URL paths or query parameters, it is safe to use encodeURIComponent and then incorporate the result at the appropriate position. In web development, URL encoding is frequently used for form data submission (application/x-www-form-urlencoded) and API request parameter construction.
Frequently Asked Questions (FAQ)
Q. What is the difference between encodeURIComponent and encodeURI?
A. encodeURIComponent encodes URL-structural characters like ":", "/", "?", "#", "&", "=" as well, while encodeURI does not encode these. Use encodeURIComponent for parameter values and encodeURI for entire URLs.
Q. Can non-ASCII URLs be converted correctly?
A. Yes, URLs containing non-ASCII characters can be correctly encoded and decoded. Conversion is based on UTF-8 encoding.
Q. What causes decode errors?
A. Errors occur when the percent encoding format is invalid (e.g., when % is not followed by valid hexadecimal digits). Please check the input content.