URL Encoder

URL encode text for safe use in web addresses. Free online percent-encoding tool.

URL Encoding Reference Table

Below is a complete reference of reserved and common unreserved characters, along with their percent-encoded values.

Character Encoding Name
(space)%20Space
!%21Exclamation mark
"%22Double quote
#%23Number sign / Hash
$%24Dollar sign
%%25Percent sign
&%26Ampersand
'%27Single quote
(%28Left parenthesis
)%29Right parenthesis
*%2AAsterisk
+%2BPlus sign
,%2CComma
/%2FForward slash
:%3AColon
;%3BSemicolon
=%3DEquals sign
?%3FQuestion mark
@%40At sign
[%5BLeft square bracket
]%5DRight square bracket
é%C3%A9e with acute accent
à%C3%A0a with grave accent
ç%C3%A7c with cedilla

encodeURIComponent vs encodeURI

In JavaScript, developers often wonder whether to use encodeURI() or encodeURIComponent(). Here is the difference:

  • encodeURI() is used to encode a complete URL. It ignores protocol prefix, domain name, and path characters like :, /, ?, &.
  • encodeURIComponent() is used to encode a component of a URL (like a query string parameter). It encodes everything, including /, ?, =, and &.
// Example of encodeURI
const fullUrl = "https://example.com/search page?query=hello world";
console.log(encodeURI(fullUrl)); 
// Output: https://example.com/search%20page?query=hello%20world

// Example of encodeURIComponent
const param = "hello & world";
const baseUrl = "https://example.com/?query=";
console.log(baseUrl + encodeURIComponent(param));
// Output: https://example.com/?query=hello%20%26%20world

Reserved vs Unreserved Characters (RFC 3986)

According to RFC 3986, characters in URLs are divided into two main categories:

  • Reserved characters: Characters that sometimes have special meaning (e.g., : / ? # [ ] @ ! $ & ' ( ) * + , ; =). They must be percent-encoded if they are used as data rather than delimiters.
  • Unreserved characters: Characters that have no special meaning in a URL context (e.g., uppercase and lowercase letters, decimal digits, hyphen, period, underscore, and tilde). These do not need to be encoded.

Frequently Asked Questions

How do I escape a space in a URL?

To escape a space in a URL, you replace it with the percent-encoded value %20. In some specific contexts like application/x-www-form-urlencoded data, a space can also be represented as a plus sign (+).

What is %20 in a URL?

%20 is the percent-encoded representation of a space character. Because spaces are not allowed in URLs, they must be converted to %20 so web browsers and servers can process the address correctly.

What characters are not allowed in URLs?

Characters like spaces, quotation marks ("), angle brackets (<, >), backslashes (\), carets (^), backticks (`), curly braces ({, }), and vertical bars (|) are inherently unsafe or reserved and must be percent-encoded to be included in a URL.

What is percent encoding?

Percent-encoding (also known as URL encoding) is a mechanism for encoding information in a Uniform Resource Identifier (URI). It converts unsafe or reserved characters into a percentage sign (%) followed by two hexadecimal digits that represent the character's ASCII or UTF-8 value.

Should I use encodeURI or encodeURIComponent?

Use encodeURI() when you need to encode a full, complete URL without breaking its structure. Use encodeURIComponent() when you are encoding a specific piece of data, such as a query string parameter, to ensure characters like = or & don't break the URL format.

Related Tools

Need to do the reverse? Use our URL Decoder tool. Creating SEO-friendly links? Try our Slug Generator.