The Complete Guide to URL Encoding: Why Your Links Are Broken

Why Spaces Break the Internet

The internet's address system (URLs) was designed to only handle a specific set of safe ASCII characters. Spaces are not allowed. If you try to send a request like example.com/my file.pdf, the server interprets the space as the end of the URL, and your request fails. To fix this, browsers and servers use Percent Encoding.

How Encoding Works

Percent encoding replaces unsafe characters with a % followed by two hexadecimal digits representing their ASCII value. The most common example is the space character, which becomes %20. Other common encodings include:

encodeURI vs. encodeURIComponent

For JavaScript developers, knowing which function to use is critical:

Debugging Broken Links

If you see a "400 Bad Request" error, it's often because a reserved character wasn't encoded properly. Use our URL Encoder to fix your strings instantly.

Related Tools

Try the tools from this guide