Developer tools on how to parse, decode, and encode a URL:
URL Encoding & Decoding
A URL may contain some special characters considered reserved and should be encoded if such a character
is used as part of the URL. For example, the character & is encoded as %26.
URL encoding is the act of encoding certain characters of the url by replacing them by their hexadecimal value which consists of 3 characters: The first character is '%', and the two other characters are the hex values.
URL decoding works in reverse to URL encoding. Here's the list of the reserved characters
| ! | * | ' | ( | ) | ; | : | @ | & | = | + | $ | , | / | ? | % | # | [ | ] |
| Example of a reserved character | Encoded |
|---|---|
| & | %26 |
| : | %3A |
| / | %2F |
| = | %3D |
| + | %2B |
Using Java:
Using JavaScript:
- encodeURI: This function encodes special characters, except: , / ? : @ & = + $ #
- decodeURI
- urldecode: Encodes a URI component including special characters
Using Perl:
- APR::URI: API for URI manipulations
- uri_escape & uri_unescape
Using PHP:
- parse_url: Parse a URL and return its components
- http_build_query: Generate URL-encoded query string
- urldecode: Decodes URL-encoded string
- urlencode: URL-encodes string
Using Python:
- urlparse: Parse URLs into components
- urllib.urlencode
- urllib.quote
- urllib.unquote
Using Ruby: