URL Encoder
Encode special characters for URLs.
URL Encoder
ReadyWhat Is URL Encoding?
URL encoding (also called percent-encoding) is the process of converting characters that are not allowed or have special meaning in a URL into a safe format that can be transmitted over the internet. Each unsafe character is replaced with a percent sign (%) followed by two hexadecimal digits representing the character's ASCII or UTF-8 byte value. For example, a space becomes %20, an ampersand becomes %26, and the Arabic letter م becomes %D9%85. The Toolsiro URL Encoder provides three modes: full URL encoding, single component encoding, and a URL parameter builder that constructs properly encoded query strings from key-value pairs.
Why URL Encoding Is Necessary
URLs can only contain a limited set of safe ASCII characters. Characters outside this safe set — including spaces, non-Latin scripts (Arabic, Chinese, Hebrew), punctuation marks like #, &, ?, =, and binary data — must be encoded before they can appear in a URL.
Without URL encoding, a URL like https://example.com/search?q=كتب عربية would break most web servers and browsers because:
- The space between "كتب" and "عربية" is not allowed in URLs.
- The Arabic characters are multi-byte UTF-8 sequences that some systems cannot handle in raw form.
After encoding: https://example.com/search?q=%D9%83%D8%AA%D8%A8%20%D8%B9%D8%B1%D8%A8%D9%8A%D8%A9
encodeURI vs encodeURIComponent — The Difference
JavaScript provides two functions for URL encoding, and they behave differently:
- encodeURI(url): Encodes a complete URL. It does not encode characters that have special meaning in URLs:
; , / ? : @ & = + $ #. Use this when encoding a full URL where you want to preserve its structure. - encodeURIComponent(value): Encodes a single URL component (a query parameter value, path segment, or fragment). It encodes everything except:
A–Z a–z 0–9 - _ . ! ~ * ' ( ). Use this for individual values that will appear as part of a query string.
The key difference in practice: if you have a URL parameter value that contains & or =, you must use encodeURIComponent — otherwise these characters will be interpreted as parameter separators by the server.
Example: to build ?q=bread & butter correctly:
- Correct:
?q=+encodeURIComponent("bread & butter")=?q=bread%20%26%20butter - Wrong:
?q=bread & butter— the server reads this as two parameters:q=breadandbutter
Percent-Encoding Reference — Common Characters
- Space →
%20(or+in HTML form encoding) !→%21"→%22#→%23$→%24%→%25&→%26'→%27(→%28)→%29+→%2B,→%2C/→%2F:→%3A;→%3B=→%3D?→%3F@→%40[→%5B
Arabic and Unicode URL Encoding
Modern browsers and servers support Internationalized Resource Identifiers (IRIs), which allow Unicode characters (including Arabic) in URLs. However, at the protocol level, these characters are still transmitted as percent-encoded UTF-8 byte sequences. When you copy a URL containing Arabic text from your browser's address bar, it may display as readable Arabic (IRI form) but the underlying transmitted form is percent-encoded.
Arabic letters use two UTF-8 bytes each and encode as two %XX%XX sequences. For example, the Arabic word "مرحبا" (Hello) encodes as: %D9%85%D8%B1%D8%AD%D8%A8%D8%A7.
Related Tools
To reverse the process, use the URL Decoder. For encoding binary data in text form, use the Base64 Encoder / Decoder.