Community for developers to learn, share their programming knowledge. Register!
Tools

URL Encode


URL encoding is the process of converting characters that are not allowed in URLs into a format that can be safely transmitted over the Internet. This encoding is necessary because URLs can only contain a limited set of characters, such as letters, numbers, and certain symbols, and any other characters must be encoded.


There are 11 characters which are not encoded by Full URL, but encoded by Query String.

Encode Import from clipboard Import from file Sample data

Copy Download


What is URL Encode?

URL encoding is a mechanism for encoding information in a Uniform Resource Identifier (URI) under certain circumstances. It is used for encoding special characters in a URL, such as spaces, and non-ASCII characters, so that they can be safely transmitted over the internet. The process replaces these characters with a percent symbol % followed by two hexadecimal digits that represent the ASCII code of the original character.

Example:

<!-- Input: -->
https://useful.codes

<!-- Output: -->
https%3A%2F%2Fuseful.codes

Why is URL Encode needed?

URL encoding is needed because URLs (Uniform Resource Locators) can only be sent over the Internet using the ASCII character-set. Certain characters, such as spaces and punctuation, are not allowed in a URL. URL encoding replaces these disallowed characters with a percent symbol % followed by two hexadecimal digits that represent the ASCII code of the original character. This encoding ensures that the URL remains intact and can be safely transmitted over the Internet. Additionally, URL encoding is used to encode the parameter values passed in the query string part of a URL to ensure that they are properly transmitted and interpreted by the server.

How does URL Encode work?

URL encoding works by replacing certain characters in a URL string with their hexadecimal representation preceded by the percent symbol (%). The hexadecimal representation is the ASCII code of the original character, expressed in hexadecimal form. The process of URL encoding involves replacing certain characters as follows:

  • Space is replaced with %20
  • The percent symbol itself is replaced with %25
  • The ampersand symbol is replaced with %26
  • The plus symbol is replaced with %2B
  • The forward slash symbol is replaced with %2F
  • Non-ASCII characters are replaced with their UTF-8 hexadecimal representation, preceded by %

Examples of URL Encode

When you search for a term on a website, the search query is often appended to the URL as a query string. For example, searching for "banana cake recipe" on a food website might result in the following URL: https://www.food.com/search?q=banana%20cake%20recipe. The spaces in the search query are encoded as %20.

Is URL Encode secure?

URL encoding is not a security measure. It is a way to encode special characters in a URL to ensure that the URL remains valid and can be transmitted over the internet. While URL encoding can prevent some issues with data transmission, it should not be relied upon as a means of security. It is important to implement proper security measures, such as encryption and authentication, to ensure the confidentiality and integrity of data transmitted over the internet.