URL Encoder & Decoder
Encode special characters for safe URL transmission, or decode percent-encoded URLs instantly.
URL encoding reference
Common encoded characters
Space → %20 & → %26 = → %3D ? → %3F # → %23 + → %2B / → %2F
encodeURIComponent vs encodeURI
Use encodeURIComponent for query parameter values. Use encodeURI for full URLs where you want to preserve slashes, colons, and query structure.
When to use it
Encode strings before adding them as query parameters, inside href attributes, or when sending special characters like &, =, #, or spaces in URLs.
URL Encoding — Why Spaces Become %20 and How to Do It Right
URLs can only contain a limited set of safe characters: letters (A–Z, a–z), digits (0–9), and a handful of special characters like hyphens and underscores. Everything else — spaces, ampersands, equals signs, non-ASCII characters — must be percent-encoded. The name "percent encoding" comes from the format: a percent sign followed by two hexadecimal digits representing the character's ASCII code.
Why spaces become %20
A space character has ASCII code 32 decimal, which is 20 in hexadecimal. So a space becomes %20. An ampersand (&) has ASCII code 38 = 0x26, becoming %26. An equals sign (=) is 61 = 0x3D, becoming %3D. The conversion is purely mechanical — character to ASCII to hex to percent-hex.
encodeURI vs encodeURIComponent
JavaScript has two encoding functions with an important difference. encodeURI() encodes a full URL — it preserves structural characters like / : ? & = because they have meaning in a URL. encodeURIComponent() encodes a value to be placed inside a URL — it encodes those structural characters too. Always use encodeURIComponent() for query parameter values.
The + vs %20 confusion
In HTML form submissions (application/x-www-form-urlencoded format), spaces become + instead of %20. Both represent a space, but in different contexts. %20 is correct for URL paths and modern APIs. + only works in query strings when the server expects form encoding. When in doubt, use %20 — it works everywhere.
Frequently asked questions
encodeURIComponent(value). In Python: urllib.parse.quote(value). Failure to encode can break URLs, cause security vulnerabilities like open redirect attacks, or result in incorrect query parsing.