URL encoder and decoder
Percent-encode a value or a whole URL, or decode one. Explains encodeURIComponent versus encodeURI, detects double encoding and says where decoding fails.
The result appears here.Everything you type here stays in your browser. Nothing is sent to HardenKit or to anyone else.
How to use the URL encoder and decoder
- Choose whether to encode a value, encode a whole URL, or decode.
- Paste the text. The result updates as you type.
- When decoding form data or a query string, turn on "Read + as a space".
- Read any warning about double encoding, then copy the result.
About this tool
A URL may only hold a small set of characters, and some of those have a job: ? starts the query, & separates parameters, / separates path segments, # starts the fragment. Percent-encoding writes any other byte as % and two hex digits, so a space becomes %20 and é, which is two bytes in UTF-8, becomes %C3%A9. That lets any text travel inside a URL without being mistaken for its structure.
The question is always what you are encoding. For one value, such as a search term or a redirect target placed in a parameter, everything with a meaning must be escaped, including / ? & and =. That is encodeURIComponent, the first mode here. For a complete URL you want to keep the structure and escape only what is never allowed, such as spaces. That is encodeURI. Using the second where the first is needed is how a value with an & in it silently adds a parameter.
Decoding has its own trap. Text that is encoded twice, such as %252F for a slash, survives one decoding as %2F and becomes a slash at the next. Attackers use that to pass a filter that decodes once in front of an application that decodes again. This tool tells you when the input has more than one layer, and where a broken escape is.
Sources
Questions
encodeURI is for a whole URL and leaves the characters that structure it, such as : / ? # & and =. encodeURIComponent is for a single value and escapes those too. Use encodeURIComponent for anything you put inside a query parameter or a path segment.
%20 is the percent-encoding of a space and is valid everywhere in a URL. The + comes from HTML form encoding, application/x-www-form-urlencoded, and means a space only in a query string or a form body. In a path, a + is a literal plus sign.
Encoding text that is already encoded, so % becomes %25 and %2F becomes %252F. It happens by accident when two layers both encode. It is also an attack technique: a filter decodes once and sees harmless text, and a later component decodes again and gets ../ or a script tag.
Either a % is not followed by two hex digits, as in "100%", or the bytes do not form valid UTF-8, which happens when the text was encoded in another character set such as Latin-1. This tool reports the position of the problem.