Encode or decode any URL instantly with our free tool. Perfect for safe web data sharing, query parameters, and API development.
encodeURIComponent encodes all characters except: A-Z a-z 0-9 - _ . ! ~ * ' ( ).
encodeURI does not encode: A-Z a-z 0-9 ; , / ? : @ & = + $ - _ . ! ~ * ' ( ).
URL encoding, also known as percent-encoding, is a mechanism for encoding information in a Uniform Resource Identifier (URI). It converts special characters into a format that can be transmitted over the internet safely, as URLs can only be sent over the Internet using the ASCII character set.
URL encoding replaces unsafe ASCII characters with a "%" followed by two hexadecimal digits. For example:
The encoder scans the URL to identify characters that are not allowed or have special meaning in URLs, such as spaces, ampersands, question marks, etc.
Each unsafe character is converted to its ASCII code value in decimal format.
The decimal ASCII code is converted to its two-digit hexadecimal representation.
The hexadecimal value is prefixed with a percent sign (%) to create the final encoded representation.
| Character | URL Encoded | Description |
|---|---|---|
| Space | %20 | Space character |
| ! | %21 | Exclamation mark |
| " | %22 | Double quote |
| # | %23 | Hash/pound |
| $ | %24 | Dollar sign |
| % | %25 | Percent sign |
| & | %26 | Ampersand |
| ' | %27 | Single quote |
| ( | %28 | Left parenthesis |
| ) | %29 | Right parenthesis |
| * | %2A | Asterisk |
| + | %2B | Plus sign |
| , | %2C | Comma |
| / | %2F | Forward slash |
| : | %3A | Colon |
| ; | %3B | Semicolon |
| = | %3D | Equals sign |
| ? | %3F | Question mark |
| @ | %40 | At symbol |
| [ | %5B | Left square bracket |
| ] | %5D | Right square bracket |
Encode URL parameters containing special characters to ensure proper transmission and parsing.
Properly encode data in API requests and responses to maintain data integrity across systems.
Encode form data when using GET method to prevent URL structure issues.
Encode file names and paths containing special characters for web accessibility.
Encode non-ASCII characters in URLs to support international domain names and content.
Encode email addresses in mailto links to ensure proper functionality across email clients.
| Aspect | encodeURI | encodeURIComponent |
|---|---|---|
| Purpose | Encodes complete URIs | Encodes URI components (query strings) |
| Characters Encoded | Fewer characters encoded | More characters encoded |
| Preserved Characters | A-Z a-z 0-9 ; , / ? : @ & = + $ - _ . ! ~ * ' ( ) | A-Z a-z 0-9 - _ . ! ~ * ' ( ) |
| Common Use | Encoding entire URLs | Encoding query parameters, fragments |
encodeURI: Use when you need to encode a complete URL but keep it functional as a clickable link.
encodeURIComponent: Use when encoding individual URL components like query parameters, where special characters could break the URL structure.
URL encoding uses percent-encoding (% followed by two hex digits) to make strings safe for URLs, while HTML encoding uses character entities (& followed by entity name/number and ;) to make strings safe for HTML content. They serve different purposes and should not be used interchangeably.
You should use URL encoding whenever you're including dynamic data in URLs, particularly in query parameters, path segments, or fragments. This includes user-generated content, search terms, file names with special characters, and any data that might contain reserved URL characters.
Proper URL encoding generally doesn't negatively impact SEO. Search engines can handle encoded URLs correctly. However, clean, readable URLs are generally preferred for SEO. Use encoding only when necessary for special characters, and consider using URL slugs or friendly URLs for better user experience and SEO.
Spaces are not allowed in URLs as they're considered unsafe characters. The %20 encoding represents a space character in hexadecimal format (ASCII code 32 in decimal is 20 in hexadecimal). Some systems also accept the plus sign (+) as an alternative for spaces in query strings, though %20 is the standard.
Generally, you should encode specific parts of URLs rather than entire URLs. Use encodeURIComponent for query parameters, fragments, and path segments that contain special characters. Use encodeURI if you need to encode a complete URL but preserve its functionality as a clickable link.
Alphanumeric characters (A-Z, a-z, 0-9) and these special characters typically don't need encoding: - _ . ! ~ * ' ( ). However, the specific safe characters depend on whether you're using encodeURI (more characters preserved) or encodeURIComponent (fewer characters preserved).