URL encoding explained — what percent-encoding is and how it works
URL encoding converts characters like spaces and symbols into a safe format for URLs. Learn what it means and when you need to encode URLs.
Why URLs need encoding
A URL can only contain a specific set of safe ASCII characters: letters, digits, and a few special characters like -, _, ., and ~. Any other character — including spaces, accented letters, Arabic script, Chinese characters, and special symbols — must be converted to a percent-encoded format before appearing in a URL.
How percent-encoding works
Each unsafe character is replaced by a percent sign (%) followed by its two-digit hexadecimal ASCII code. For example, a space (ASCII 32 = 0x20) becomes %20. The @ sign (ASCII 64 = 0x40) becomes %40. The # sign (ASCII 35 = 0x23) becomes %23.
Common encoded characters
- Space → %20
- ! → %21
- # → %23
- $ → %24
- & → %26
- = → %3D
- ? → %3F
- @ → %40
- + → %2B (when + itself is the value, not a space placeholder)
URL encoding in practice
When you build a search results URL, the search query goes in the URL as a parameter. For example, searching for "free online tools" on a site might produce: /search?q=free%20online%20tools. The space is encoded as %20 so the URL remains valid. When the server receives this request, it decodes %20 back to a space before processing the search.
encodeURI vs encodeURIComponent in JavaScript
encodeURI() encodes a full URL but leaves structural characters like /, ?, =, & untouched. encodeURIComponent() encodes everything including structural characters — use it when encoding individual query parameter values. This tool uses encodeURIComponent behavior for accurate encoding of values.
Encode and decode URLs instantly with the URL Encoder Decoder tool.