URL Encoder/Decoder

Percent-encoding for web URLs and query parameters

URL Encoding Guide

Understanding percent-encoding and its importance in web development.

What is URL Encoding?

URL encoding (percent-encoding) converts characters into a format that can be transmitted over the internet. Special characters are replaced with a "%" followed by two hexadecimal digits.

Example: Space becomes %20, & becomes %26

encodeURI vs encodeURIComponent

encodeURI() encodes a complete URL but leaves functional characters like :, /, ?, & intact.
encodeURIComponent() encodes everything, including special characters, making it suitable for query parameters.

URL Encoding Examples

Original URL

https://example.com/search?q=hello world&page=1

Encoded URL

https://example.com/search?q=hello%20world&page=1
Note: The space in "hello world" is encoded as %20. Other special characters like &, ?, = are preserved in the URL path.

Common URL Encodings

Character Encoded Description
Space %20 Space character
! %21 Exclamation mark
# %23 Hash/fragment
$ %24 Dollar sign
& %26 Ampersand
+ %2B Plus sign