URL encoding guide
URL encode vs decode
Encoding prepares text for a URL. Decoding turns percent-encoded text back into something humans can read.
The difference
Use encode when a value is going into a URL. Use decode when you are reading a value that has already been escaped, such as a query string copied from logs.
Example
Encode: url space encoder
Decode: url%20space%20encoder
Encoded: url%20space%20encoder
Decoded: url space encoder
How to choose
- Choose Encode for raw text, spaces, symbols, and callback values before they go into a URL.
- Choose Decode for percent-encoded text when you need to inspect what it says.
- If decoding still leaves percent signs, the value may have been encoded more than once.
A simple mental model
Encode before text goes into a URL. Decode when you are reading a URL and need to understand what a value says.
If the result still contains percent signs after decoding, it may be encoded in layers. Decode once, inspect the text, then decide whether another pass makes sense.
Common mistakes
- Decoding a value before sending it to an endpoint that expects encoded text
- Encoding an already encoded value and changing %20 into %2520
- Using a decoded callback URL directly inside another query parameter
- Assuming readable text is always safe to paste into a URL
Related problems
FAQ
What does URL encoding do?
It replaces unsafe characters with percent-encoded sequences, such as converting a space to %20.
What does URL decoding do?
It converts percent-encoded sequences back into readable characters.
Why do I sometimes need to decode twice?
Some systems encode values in layers. Decode one layer at a time so you can see what changed.