ToolBoxOnline
Developer

URL Encoding Explained: Why Your Links Break and How to Fix Them

Spaces become %20, ampersands become %26. URL encoding is the difference between a link that works and one that breaks. Here is when you need it.

URL encoderURL encodingpercent encodingencode URL onlineURL decoderfix broken links

You paste a URL into a message and it is 200 characters of gibberish. Tracking parameters, session IDs, UTF-8 characters double-encoded. The person receiving it cannot tell what the link actually is. A URL encoder fixes this in seconds.

URL encoding is one of those things you do not think about until a link breaks. Here is what it does and the three situations where you need it.

What URL Encoding Actually Does

URLs can only contain a limited set of characters: A-Z, a-z, 0-9, hyphen, underscore, period, and tilde. Everything else — spaces, symbols, non-Latin characters, emoji — must be percent-encoded to work reliably.

Space becomes %20. Ampersand becomes %26. The Chinese characters for "hello" become %E4%BD%A0%E5%A5%BD. The browser decodes these back to readable text in the address bar, but the actual URL underneath is percent-encoded. If you skip encoding, the URL either breaks or produces unpredictable results depending on the browser and server.

Three Times You Need URL Encoding

Building query strings. If your URL includes user input — a search term, a username, a form field — encode it. A search for "coffee & tea" needs the ampersand encoded as %26, otherwise the server interprets everything after & as a separate parameter. Results: broken query, missing data, confused users.

Links with special characters. Square brackets in URLs (common in PHP-style query strings) should be encoded. Curly braces, pipes, backslashes — all need encoding. The encoder handles them automatically.

Non-Latin text in URLs. If your URL contains Arabic, Chinese, Japanese, Korean, or any non-Latin script, it must be percent-encoded. Some browsers do this automatically. Many do not. Assume it will break and encode it preemptively.

Common Mistakes

Double encoding. You encode a URL, then encode it again. %20 becomes %2520 (the % gets encoded to %25). The browser decodes once, leaving %20 instead of a space. This happens when URL encoding is applied at multiple layers — your code encodes, then your framework encodes again.

Encoding the entire URL. Only encode the parts that need it — query parameter values, path segments with special characters. Encoding the entire URL including https:// produces broken results. The free URL encoder handles this correctly.

Try it: paste a messy URL and see what gets encoded. The tool also decodes — paste a percent-encoded URL to see the original text.

Tools mentioned in this article

Share this tool