Encode URLs for safe transmission or decode encoded URLs back to readable text.
URL encoding converts characters that are not allowed in URLs into a format that can be transmitted. For example, a space becomes %20.
When passing data in query strings, when including special characters in URLs, or when working with APIs that require encoded parameters.
encodeURIComponent encodes all special characters including /, ?, # and &. Use it for individual parameter values. encodeURI only encodes characters not allowed in a full URL.