URL Encoding Explained: What It Is and How to Use It
TL;DR
URLs can only contain a limited set of characters. Learn what URL encoding is, when you need it, common mistakes, and how to encode/decode URLs instantly.
You've probably noticed it before. You search for something on Google, look at the address bar, and see a mess like q=hello%20world where a simple space should be. That %20 isn't random noise. It's URL encoding at work, and understanding it saves you hours of debugging when things break in unexpected ways.
What Is URL Encoding?
URL encoding is the process of replacing characters that aren't allowed in a URL with a percent sign (%) followed by two hexadecimal digits. The hex digits represent the character's ASCII (or UTF-8) byte value.
For example, a space character has the ASCII value 32, which is 20 in hexadecimal. So a space becomes %20. An ampersand & has the ASCII value 38, or 26 in hex. It becomes %26.
The official name for this is percent encoding, defined in RFC 3986. Every browser, server, and HTTP library understands it.
Why URLs Need Encoding
URLs were designed with a strict set of allowed characters. Letters, numbers, and a handful of symbols like -, _, ., and ~ can appear in a URL without any issues. Everything else is either reserved (characters like ? and & that have special meaning in URLs) or unsafe (characters like spaces that could be misinterpreted).
Without encoding, things break quickly. Encoding fixes that by ensuring every character means exactly what you intended.
Non-ASCII characters need encoding too. A URL containing cafe with an accented e must encode the e as its UTF-8 byte sequence to work reliably across all browsers and servers.
When You Need to Encode URLs
Query parameters. Any time you pass user input as a query parameter, encode the values.
API requests. REST APIs often require encoded parameters.
Form data. When an HTML form submits via GET, the browser automatically encodes the form values into the URL.
Redirect URLs. If you're passing a full URL as a parameter, encode the entire inner URL so it's treated as a single value.
How to Encode and Decode URLs with Morphkit
The fastest way to encode or decode a URL is to use an online tool. Morphkit's URL Encoder/Decoder handles both directions instantly.
- Go to morphkit.io/tools/url-encoder-decoder
- Paste your text or URL into the input field
- Click "Encode" or "Decode"
- Copy the result
It runs entirely in your browser. Nothing gets sent to a server.
If you're working with encoded data in other formats too, Morphkit's Base64 Encoder/Decoder handles Base64 strings, and the JSON Formatter can help you clean up API responses that contain encoded URLs buried in JSON payloads.
Common URL Encoding Mistakes
Double encoding
This happens when you encode a string that's already encoded. The % signs from the first encoding get encoded again, turning %20 into %2520. If your URLs have %25 scattered through them, you're almost certainly double encoding.
Encoding the entire URL instead of just the parameters
A full URL has characters that are supposed to be there literally. If you run the whole thing through encodeURIComponent, you'll break the URL structure. Only encode the dynamic parts. Build the URL structure normally, then encode each parameter value individually before inserting it.
Start Encoding and Decoding URLs
URL encoding is one of those things you don't think about until something breaks. Next time you're debugging a URL issue, use Morphkit's URL Encoder/Decoder. Paste, click, done. No installs, no signups, and your data stays in your browser.