Encode and decode URLs for web use. Convert special characters to URL-safe format.
Encode and decode URL strings for web use
URL encoding converts special characters into a format that can be transmitted over the internet. It replaces unsafe characters with a % followed by two hexadecimal digits.
encodeURI encodes a complete URL, preserving characters like : / ? & =. encodeURIComponent encodes individual URL components and encodes all special characters.
Use URL encoding when passing data in query parameters, especially if the data contains special characters, spaces, or non-ASCII characters.