URL Encoding and Decoding Explained
Understand URL encoding — why spaces become %20, when encoding is needed, and how to encode or decode URLs online.
What Is URL Encoding?
URL encoding (also called percent-encoding) converts special characters in URLs into a format that can be safely transmitted over the internet. URLs can only contain a limited set of ASCII characters. Characters outside this set must be encoded.
The encoding format: a percent sign (%) followed by two hexadecimal digits representing the character's ASCII value.
Common encodings:
Space → %20
@ → %40
& → %26
= → %3D
→ %23
/ → %2F
+ → %2B (or space → + in query strings)
Why URL Encoding Is Necessary
URLs use certain characters for structural purposes. The & separates query parameters. The # starts a fragment. The = separates a key from its value in query strings. The / separates URL path segments.
If your URL parameter value contains these characters, it must be encoded or the URL parser will misinterpret the structure.
Example: Searching for "Hello & Goodbye" on a website without encoding:
Wrong: https://example.com/search?q=Hello & Goodbye
This breaks the URL — the parser thinks there are two parameters: q=Hello and Goodbye.
Correct: https://example.com/search?q=Hello%20%26%20Goodbye
Or: https://example.com/search?q=Hello+%26+Goodbye
When You Encounter URL Encoding
Copying URLs from browser address bars (spaces appear as %20).
API query parameters (need to encode user input).
Email links (addresses with special characters must be encoded).
Form submissions (browsers automatically encode form data).
Webhook URLs (ensure any dynamic parts are encoded).
URL Encoding vs Base64
URL encoding makes URLs safe for transmission. Base64 encodes binary data as ASCII. They serve different purposes. A URL might contain Base64-encoded data as a parameter, with the Base64 string itself URL-encoded.
Frequently asked questions
Why does my URL have %20 in it?
%20 is the URL encoding for a space character. URLs cannot contain raw spaces, so browsers and applications encode them as %20 (or sometimes + in query strings).
Do I need to URL encode API parameters?
Yes — always URL encode user-provided parameters before including them in API requests. Most HTTP libraries do this automatically, but manual string concatenation in URLs requires explicit encoding.
Put this guide into practice with our free online tool — no signup required.
Open tool