What is URL percent encoding?
URL encoding (percent-encoding) replaces characters that aren't safe inside a URL — spaces, &, =, and others — with a % followed by their hex code. This lets arbitrary text be safely embedded as a query parameter value or path segment.
The rules come from RFC 3986. Letters, digits and - . _ ~ are unreserved and never need encoding. Characters such as : / ? # & = + are reserved: they have a structural meaning in a URL, so they must be encoded when they appear inside a value. Every other character is first converted to its UTF-8 bytes, and each byte is written as % plus two hex digits — é becomes %C3%A9 and a space becomes %20.
encodeURIComponent vs encodeURI
JavaScript has two built-in percent-encoding functions. The difference is which reserved characters they leave alone.
| encodeURIComponent | encodeURI | |
|---|---|---|
| Use for | One value: a query parameter or path segment | A whole URL whose structure must survive |
| Leaves unencoded | A–Z a–z 0–9 - _ . ! ~ * ' ( ) | the same, plus ; , / ? : @ & = + $ # |
| Decoder | decodeURIComponent | decodeURI |
Given https://example.com/a b?q=1&r=a/b#top:
encodeURIgiveshttps://example.com/a%20b?q=1&r=a/b#top— only the space changes, so the URL still works.encodeURIComponentgiveshttps%3A%2F%2Fexample.com%2Fa%20b%3Fq%3D1%26r%3Da%2Fb%23top— everything is escaped, which is what you want when this whole URL is itself the value of a parameter, such as a?redirect=target.
The common bug is using encodeURI on a single value: a value of a&b stays a&b and splits into two query parameters. Build query strings with encodeURIComponent for each value, or with URLSearchParams — note that URLSearchParams writes spaces as + (form encoding), not %20.
How to use this tool
Choose Encode or Decode, then type or paste your text. This tool uses JavaScript's encodeURIComponent / decodeURIComponent — the right choice for encoding a single value (like a query parameter), since it escapes & and = too. If you needed to encode an entire URL while keeping its structure (like :// and ?) intact, you'd want encodeURI instead, which this tool does not use.
Example
Encoding name=John Doe&city=New York produces name%3DJohn%20Doe%26city%3DNew%20York.
Non-ASCII text is encoded as its UTF-8 bytes: 안녕하세요 becomes %EC%95%88%EB%85%95%ED%95%98%EC%84%B8%EC%9A%94, and decoding that string gives back the original Korean text.
FAQ
Why do I get an error when decoding?
Decoding fails when the input contains invalid percent-encoding, such as %ZZ or a truncated % sequence. Double-check you copied the full encoded string.
Why is a space encoded as %20 and not +?
Percent-encoding writes a space as %20. Using + for a space is a separate convention from HTML form encoding (application/x-www-form-urlencoded). This tool follows encodeURIComponent, so a literal plus sign is escaped: a b+c encodes to a%20b%2Bc. When decoding, a + is kept as a plus sign, not turned into a space.