URL Encoder/Decoder

Encode and decode URLs and query parameters.


                    

What is URL Encoding and why is it necessary?

URL Encoding (also called percent-encoding) is the process of converting special characters in a URL to a format that can be safely transmitted over the Internet. URLs can only contain a limited subset of ASCII characters: letters, digits, and some special characters like "-", "_", "." and "~". Any other character must be encoded using the "%XX" format where XX is the hexadecimal value of the character.

This process is essential when you need to include parameters in URLs that contain spaces, accents, symbols like "&", "=" or "#", or non-Latin characters. Without URL encoding, these characters could be interpreted as URL delimiters or cause server errors.

Practical use cases

Search parameters: When a user searches for "red shoes & cheap", the space is encoded as "%20" or "+" and the "&" as "%26", resulting in "red%20shoes%20%26%20cheap".

REST APIs: When building URLs with parameters that include emails, dates with slashes, or JSON, each value must be properly encoded to avoid HTTP 400 errors.

Social media: Links for sharing content on Twitter, Facebook, or LinkedIn require the title and description to be properly encoded.

Frequently asked questions

What is the difference between encodeURIComponent and encodeURI?

encodeURI does not encode URL-reserved characters like ":", "/", "?", "#", "[", "]", "@", "!", "$", "&", "'", "(", ")", "*", "+", ",", ";" and "=". encodeURIComponent encodes all of these characters. Use encodeURI for complete URLs and encodeURIComponent for individual parameter values.

Is a space encoded as "+" or "%20"?

Both are valid but in different contexts. In form bodies (application/x-www-form-urlencoded), spaces are encoded as "+". In the URL itself (path and query string), spaces are encoded as "%20".

Can UTF-8 characters like emojis be encoded?

Yes. Multibyte characters like emojis or Chinese characters are encoded byte by byte. For example, the emoji "๐Ÿ˜€" is encoded as "%F0%9F%98%80" (4 bytes in UTF-8).

Do I need to encode the entire URL?

No. You should only encode parameter values, not the URL structure. The protocol (https://), domain, slashes, and the "?" sign should not be encoded.

Characters that require encoding

CharacterEncodedCharacterEncoded
space%20&%26
=%3D#%23
@%40+%2B
รฑ%C3%B1รก%C3%A1