Search 110+ free tools… (e.g. json, vpn, password) ⌘K
Link Tools Dereferer Hide Referrer Link URL Shortener Affiliate Cloaker PayPal Links PayPal DonationPayPal Links Privacy Tools Password Generator Cloudflare Resolver My Referrer Torrent Tools Magnet → Torrent Torrent → Magnet Torrent Editor Pirate Bay Proxies Movierulz Proxies ExtraTorrent Proxies Dev Tools Base64 Encoder Hash Generator HTTP Headers Disposable Email Checker Company Blog About Us Contact Anonymize Free
General

URL Encoding Explained: When and How to Encode URLs Correctly

JAY
Author
May 14, 2026 · 2 min read · 32 views
URL Encoding Explained: When and How to Encode URLs Correctly

What Is URL Encoding? URL encoding (also called percent encoding) converts characters that are not allowed in URLs into a safe format using a % sign followed by two hexadecimal digits. For example, a

What Is URL Encoding?

URL encoding (also called percent encoding) converts characters that are not allowed in URLs into a safe format using a % sign followed by two hexadecimal digits. For example, a space becomes %20, an ampersand becomes %26, and a forward slash becomes %2F.

Encode and decode URLs instantly: URL Encoder & Decoder

Why URLs Need Encoding

URLs can only contain a limited set of ASCII characters. The RFC 3986 specification defines which characters are "unreserved" (safe without encoding): A-Z a-z 0-9 - _ . ~

All other characters must be percent-encoded before being included in a URL. This includes spaces, special characters, non-ASCII characters (like accented letters and Chinese characters), and URL-reserved characters when used as data rather than delimiters.

encodeURI vs encodeURIComponent

FunctionWhat it encodesWhat it leavesUse for
encodeURI()Spaces and most special chars: / ? # [ ] @ ! $ & , ; = (URL structure)Complete URLs
encodeURIComponent()Everything except A-Z a-z 0-9 - _ . ! ~ * ( )Only alphanumerics and safe charsQuery parameter values

Code Examples

Correct — encoding a query parameter value:
var search = encodeURIComponent(userInput);
var url = "https://api.example.com/search?q=" + search;

Wrong — using encodeURI for a parameter value:
// encodeURI leaves & and = intact — breaks query strings
var url = "https://api.example.com?q=" + encodeURI("bread & butter");
// Result: ?q=bread%20&%20butter — & breaks the query string

Common URL Encoding Mistakes

1. Double Encoding

Encoding an already-encoded string produces %2520 instead of %20 (encoding the % sign). Always decode before re-encoding.

2. Not Encoding Query Values

Passing user input directly into query strings without encoding allows injection attacks and breaks APIs when input contains &, =, or #.

3. Using the Wrong Function

Using encodeURI instead of encodeURIComponent for individual query parameter values leaves characters like & and = unencoded, which breaks the query string structure.

URL Encoding Character Reference

CharacterEncodedNotes
Space%20 or ++ only valid in query strings, not paths
&%26Used to separate query params
=%3DUsed between key and value
#%23Fragment identifier
+%2B+ in query strings means space
/%2FPath separator
?%3FQuery string start
@%40Email and auth

Related Tools

🔗
Free Dereferer Tool

Strip HTTP Referer headers from any link. Fully anonymous, zero logs, instant redirect.

Anonymize a Link Now →
# General
Share on X
Rate this article
Your rating is stored anonymously. You can rate once per post.
Written by
JAY
Writer at Anonymiz

Related Articles

WhatsApp Business Link: Add WhatsApp to Your Website and Social Media
May 31, 2026 · JAY
WhatsApp Group Link: How to Create and Share Group Invite Links
May 31, 2026 · JAY
WhatsApp Link Generator: Create Click-to-Chat Links Free
May 31, 2026 · JAY
← Back to Blog
🔔 Get notified when we add new tools

No spam — one email when we launch something useful. Unsubscribe anytime.

Join 1,200+ users · No tracking · Unsubscribe anytime

Done!