How to use it
- Type or paste your text in the top box.
- Pick Encode or Decode. The result updates as you type.
- Pick the mode. Use One value for a single parameter. Use A whole URL for a full address.
- Press Copy result.
To take a URL apart, paste it in the Full URL box. The first table shows the scheme, host, port, path, query string and hash. The second table lists each query parameter with its value decoded.
The text stays in your browser. Nothing is sent to a server.
What is URL encoding?
A URL may only hold a small set of characters. Other characters are written as a percent sign and two hex digits. A space becomes %20. An ampersand becomes %26. This is also called percent-encoding.
Characters outside plain English letters are first turned into UTF-8 bytes. Each byte gets its own code. The letter é becomes %C3%A9.
One value or a whole URL?
Some characters have a job in a URL. The question mark starts the query. The ampersand splits parameters. The slash splits the path.
- One value uses
encodeURIComponent. It encodes those characters too. Use it for a value you put inside a URL, such as a search term or a file name. Then an ampersand in the value cannot be read as the start of a new parameter. - A whole URL uses
encodeURI. It leaves: / ? & = #alone and encodes only the characters that can never appear, such as spaces and accented letters.
If you encode a whole URL with the first mode, the result is no longer a link. If you encode a value with the second mode, special characters in it can break the query.
Plus signs and spaces
Web forms write a space as a plus sign. In the path of a URL, a plus sign is a plain plus. Tick treat + as a space when you decode form data or a query string. The parameter table always reads a plus sign as a space, because that is what web servers do with a query string.
Errors
Decoding fails when a percent sign is not followed by two hex digits. The tool tells you which character is wrong. The usual cause is a plain percent sign in the text, as in 100%. Write it as %25.
Decoding also fails when the codes are not valid UTF-8. That happens with text from an old system that used another character set, or with a URL that was cut off.
Questions
What is the difference between %20 and + for a space?
Both mean a space inside a query string. %20 works everywhere in a URL. The plus sign only means a space in form data and query strings. When in doubt, use %20.
Why does my text have codes like %2520?
It was encoded twice. The first pass turned a space into %20. The second pass turned the percent sign into %25. Decode it two times to get the text back.
Which port does a URL use when none is written?
The scheme decides. http uses port 80 and https uses port 443. The parts table shows the default port and marks it as the default.