导航菜单
首页 >  URL Encoder Cheet sheet  > HTML URL Encoding

HTML URL Encoding

A Uniform Resource Locator (URL) is simply the address of a website to access the website content like www.geeksforgeeks.org. But certain characters are allowed to be used in the URL like alphabets A-Z and a-z, numbers 0-9, and a few special characters. They can be used as it is but the rest of the characters that are not in this list are used after encoding them to a suitable form. URL Encoding is the process of converting the URL into a valid format that is accepted by web browsers. 

URL Encoding takes place by replacing all the characters that are not allowed by a % sign followed by two hexadecimal digits. These two hexadecimal values represent the numerical values of the character in the ASCII character set. For example, a space is not acceptable in a URL and is replaced by a ‘%20’ or a ‘+’ sign while encoding. Similarly, a $ sign is replaced by ‘%24’. 

Syntax:

A web address follows these syntax rules:

scheme://prefix.domain:port/path/filename//Examplehttps://www.geeksforgeeks.org/Scheme: It specifies the protocol used for communication, such as “https://” for secure communication or “http://” for unsecured communication.Prefix: It is an optional subdomain or www indicating the location of the resource within the domain.Domain: Identifies the website’s primary address, like “example.com”, indicating its unique location on the Internet.Port: Optional and signifies a specific endpoint for communication. Common values are 80 for HTTP and 443 for HTTPS.Path:It specifies the location or directory on the server where the resource is located.Filename: It refers to the specific file or resource within the specified path.

Table of Content

Reserved CharactersUnsafe charactersURL Encoded CharactersReserved Characters

Certain characters sometimes have special meanings in the URL and it can be used in both ways. For example, the ‘/’ character is a reserved character and it has a special meaning when being used as a delimiter to separate the paths of a URL. Here it is used by encoding it to ‘%2F’. Else when it has no special purpose it can be used normally. There are many reserved characters which are listed below:

CharacterEncoded Form!%21*%2A‘%27(%28)%29;%3B:%3A@%40&%26=%3D+%2B$%24,%2C/%2F?%3F#%23[%5B]%5D

Some characters need to be encoded while some don’t need to be. Here is the classification shows the group of characters that need to be encoded.

Safe Characters: Alphanumeric i.e. 0-9, a-z, and A-Z, special characters $, -, _, ., +, !, *, ‘, (, ), are reserved characters used for their reserved purposes. These characters have no need to be encoded.ASCII Control characters: It includes characters ranging from 00-1F in hex (0-31 decimal) and 7F (127 decimal). These characters needs to be encoded.Non-ASCII Control characters: It includes 80-FF in hex (128-255 decimal). These characters needs to be encoded.Reserved characters: These characters are used for a special purpose and they require encoding.Unsafe characters: This character can be misunderstood within URLs for various reasons. So it requires encoding. The characters are unsafe because they are used as the delimiters around URLs in free text, the quote mark (” “) is unsafe as it is used to delimit URLs in some systems. Unsafe charactersCharacterEncoded Formspace%20“%22%3E#%23%%25{%7B}%7D|%7C\%5C^%5E~%7E[%5B]%5DURL Encoded CharactersCHARACTERENCODED FORMbackspace%08tab%09linefeed%0Ac return%0Dspace%20!%21“%22#%23$%24%%25&%26‘%27(%28)%29*%2A+%2B,%2C–%2D.%2E/%2F0%301%312%323%334%345%356%367%378%389%39:%3A;%3B%3E?%3F@%40A%41B%42C%43D%44E%45F%46G%47H%48I%49J%4AK%4BL%4CM%4DN%4EO%4FP%50Q%51R%52S%53T%54U%55V%56W%57X%58Y%59Z%5A[%5B\%5C]%5D^%5E_%5F`%60a%61b%62c%63d%64e%65f%66g%67h%68i%69j%6Ak%6Bl%6Cm%6Dn%6Eo%6Fp%70q%71r%72s%73t%74u%75v%76w%77x%78y%79z%7A{%7B|%7C}%7D~%7E %7F`%E2%82%AC%81‚%E2%80%9Aƒ%C6%92„%E2%80%9E…%E2%80%A6†%E2%80%A0‡%E2%80%A1ˆ%CB%86‰%E2%80%B0Š%C5%A0‹%E2%80%B9Œ%C5%92%C5%8DŽ%C5%BD%8F%C2%90‘%E2%80%98’%E2%80%99“%E2%80%9C”%E2%80%9D•%E2%80%A2–%E2%80%93—%E2%80%94˜%CB%9C™%E2%84š%C5%A1›%E2%80œ%C5%93%9Dž%C5%BEŸ%C5%B8 %C2%A0¡%C2%A1¢%C2%A2£%C2%A3¤%C2%A4¥%C2%A5¦%C2%A6§%C2%A7¨%C2%A8©%C2%A9ª%C2%AA«%C2%AB¬%C2%AC­%C2%AD®%C2%AE¯%C2%AF°%C2%B0±%C2%B1²%C2%B2³%C2%B3´%C2%B4µ%C2%B5¶%C2%B6·%C2%B7¸%C2%B8¹%C2%B9º%C2%BA»%C2%BB¼%C2%BC½%C2%BD¾%C2%BE¿%C2%BFÀ%C3%80Á%C3%81Â%C3%82Ã%C3%83Ä%C3%84Å%C3%85Æ%C3%86Ç%C3%87È%C3%88É%C3%89Ê%C3%8AË%C3%8BÌ%C3%8CÍ%C3%8DÎ%C3%8EÏ%C3%8FÐ%C3%90Ñ%C3%91Ò%C3%92Ó%C3%93Ô%C3%94Õ%C3%95Ö%C3%96×%C3%97Ø%C3%98Ù%C3%99Ú%C3%9AÛ%C3%9BÜ%C3%9CÝ%C3%9DÞ%C3%9Eß%C3%9Fà%C3%A0á%C3%A1â%C3%A2ã%C3%A3ä%C3%A4å%C3%A5æ%C3%A6ç%C3%A7è%C3%A8é%C3%A9ê%C3%AAë%C3%ABì%C3%ACí%C3%ADî%C3%AEï%C3%AFð%C3%B0ñ%C3%B1ò%C3%B2ó%C3%B3ô%C3%B4õ%C3%B5ö%C3%B6÷%C3%B7ø%C3%B8ù%C3%B9ú%C3%BAû%C3%BBü%C3%BCý%C3%BDþ%C3%BEÿ%C3%BFHTML URL Encoding – FAQsWhat is URL encoding?

URL encoding converts special characters in URLs into a format that can be transmitted over the internet, using percent signs (%) followed by hexadecimal codes.

Why is URL encoding necessary?

URL encoding ensures that special characters (like spaces, ampersands, or slashes) are correctly interpreted by browsers and servers without causing errors.

How do you encode a space in a URL?

A space is encoded as %20 or + in URLs, e.g., https://example.com/my%20page or https://example.com/my+page.

How are reserved characters encoded?

Reserved characters like &, /, ?, and = are encoded to avoid conflicts with URL syntax. For example, & becomes %26.

What is the difference between URL encoding and decoding?

URL encoding converts special characters into percent-encoded format, while URL decoding converts percent-encoded characters back to their original form.

authorprakhar7NewsImprovePrevious ArticleHTML CharsetsNext ArticleHTML Forms

相关推荐: