How to Use a URL Encoder: A Practical Workflow That Doesn't Break Links
Disclaimer: This article describes a browser-based workflow. Nothing you paste into the encoder is uploaded; the page runs the transformations locally.
The support ticket was short. A customer searched for rain jacket, landed on a page of results for rain%2520jacket, and got nothing. Nobody had typed %25. The value had simply been encoded twice on its way through a redirect.
Percent-encoding itself is trivial. What breaks links is applying it to the wrong part of a URL, or applying it a second time to something that was already encoded.
The short version: encode the value, not the whole URL. Use Strict (encodeURIComponent) for anything that sits after a = in a query string; use Standard (encodeURI) when you are preparing a complete URL and want its structure left intact. Encode exactly once, and decode before you edit anything you received.
Two Modes, and the One Job Each Does
Four controls on the URL encoder matter more than the input box: Encode versus Decode, and Strict versus Standard. They answer different questions, and mixing them up is how you get a link that looks fine and still 404s.
| Mode | What it leaves untouched | Use it for | What goes wrong if you pick it by mistake |
|---|---|---|---|
StrictencodeURIComponent |
Only the unreserved characters A–Z a–z 0–9 - _ . ! ~ * ' ( ) |
A single parameter value, a search term, a filename, a path segment | Applied to a whole URL, it encodes ://, ? and & as well, so the result is one giant value rather than a URL |
StandardencodeURI |
The reserved structure : / ? # [ ] @ & = + $ , ; plus the unreserved set above, including ! ' ( ) * |
A complete URL you are about to paste into an email, a spreadsheet or a redirect field | Applied to a parameter value, it leaves & and = alone, so your value silently splits into extra parameters |
Two examples show the difference. Take https://example.com/search?q=hello world:
- Standard gives
https://example.com/search?q=hello%20world. The space is fixed; the structure survives. - Strict gives
https%3A%2F%2Fexample.com%2Fsearch%3Fq%3Dhello%20world. Technically correct percent-encoding of the string, and useless as a link.
Now take just the value a&b=c. Strict returns a%26b%3Dc, which is what you want. Standard returns it unchanged, and the server reads three parameters where you meant one.
The Five Steps, in Order
- Paste the whole URL and run Standard first. This fixes the easy problems — a literal space, a stray quote, a non-ASCII character in the path — without touching the query structure.
- Encode only the value that still breaks, using Strict. Cut it out, paste it alone, encode, put it back. The & and = quick-scenario button on the page loads exactly this case.
- Compare the two character counters. A jump of a few characters is normal. A jump of thousands means you encoded a whole document instead of one value.
- Decode once to prove the round trip. Swap the boxes and run Decode. If the output is not byte-for-byte what you started with, something upstream encoded it twice.
- Test the link in a private window. A cached response can make a broken URL look healthy in your normal browser profile.
What Gets Encoded, and What Does Not
Percent-encoding leaves a small set of characters alone because they are defined as unreserved and safe everywhere: letters, digits, and - _ . ! ~ * ' ( ). Everything else carries a meaning of its own somewhere in URL syntax, so it needs a triplet when it is used as data rather than as syntax.
| Character | Encoded | Why it matters |
|---|---|---|
| space | %20 | Illegal in a URL; many clients silently trim or truncate it |
& | %26 | Otherwise it starts a new query parameter |
= | %3D | Otherwise it splits key from value |
+ | %2B | Otherwise some parsers read it as a space |
# | %23 | Otherwise the rest of the URL becomes a fragment and never reaches the server |
/ | %2F | Needed when a slash belongs to the data, as in a filename inside a path segment |
中 | %E4%B8%AD | One UTF-8 character, three bytes, three triplets |
😀 | %F0%9F%98%80 | Four bytes, because it is outside the basic multilingual plane |
Encoding an unreserved character is not illegal. %41 is a valid A. It is noise, though: it makes URLs harder to read and harder to diff, and a few servers normalize the two forms differently.
Four Mistakes Behind Most Broken Links
1. Double encoding
%20 encoded again becomes %2520, because the percent sign is itself encoded to %25. This happens whenever a value passes through two redirects, or a client library encodes on send while the caller already encoded. The symptom: a literal %20 in what the user sees. Fix it structurally by encoding at exactly one layer, the boundary where the value leaves your code.
2. Using + for spaces in a query string
The + convention comes from application/x-www-form-urlencoded form submissions. In a query string, some frameworks decode it as a space and some do not, and the disagreement shows up as a value with a plus sign stuck in it. %20 means a space in every implementation.
3. Encoding the whole URL with Strict
The URL survives as a string but has become a single opaque value. If the output starts with https%3A%2F%2F, this is what happened.
4. Encoding keys instead of values
If a parameter name contains a character that must be escaped, encode it. If it does not, leave it alone. Cosmetic re-encoding is harmless in most stacks but breaks any signature or cache key computed over the raw query string; signed URLs hash an exact canonical form.
When Decoding Is the Right Move
Decode when you are reading, not when you are building. Three cases come up constantly: a tracking parameter that arrives as a percent-encoded URL inside another URL, a search term with %E4%B8%AD%E6%96%87 in it, and a path that 404s because a slash inside a filename was encoded and the router did not match it.
The habit that prevents most of this: decode first, edit the plain text, then encode once.
Editing an already-encoded string by hand is how a valid %20 loses a digit and becomes %2. The resulting link fails in a way that looks like a server problem rather than a typo.
Frequently Asked Questions
Should a space be + or %20?
Use %20 in a URL path or query string. The + shorthand belongs to application/x-www-form-urlencoded form bodies, and plenty of query parsers leave it alone, so a + in a query string can reach your code as a literal plus sign.
Why did my space become %20 and then %2520?
Double encoding. The first pass turned a space into %20; the second encoded the percent sign itself, so % became %25 and the sequence became %2520. Decode once, edit, then encode exactly once.
Is URL encoding a form of encryption?
No. Percent-encoding is a reversible mapping of characters to %XX triplets with no key involved. Anyone can decode it, so it hides nothing; it only makes characters safe to transport.
Why does one Chinese character turn into three percent triplets?
Percent-encoding works on UTF-8 bytes, not characters. Most CJK characters take three bytes, so each one becomes three triplets — 中 is %E4%B8%AD. An emoji can take four.
Sources and checks: the reserved and unreserved character sets follow RFC 3986 §2.2–2.3; the encoding sets for encodeURI and encodeURIComponent follow the WHATWG URL Standard and were checked against current Chrome and Firefox builds.