World’s largest virtual agentic engineering & quality conference
URL encoding provides a way to convert special characters into a format that can be sent over the Internet. It is brought to you by TestMu AI (formerly LambdaTest), the team behind a unified software testing platform.
Encode
Copy to Clipboard
Reset
URL encoding stands for replacing certain characters in a URL with character triplets that consist of the % character followed by two hexadecimal digits. These hexadecimal digits represent the numeric values of the replaced characters. URL encoding is also called percent encoding because it uses % as an escape character.
URL addresses can only be copied over to the Internet if they use ASCII characters. These addresses contain characters outside the ASCII set, so they must first be converted into an ASCII format. URL encoding replaces unsafe ASCII characters with a percent sign (%) followed by two hexadecimal digits.
A URL (Uniform Resource Locator) is the address of a specific web page or file on the Internet. It is used to search and retrieve information on the World Wide Web. URLs usually include a protocol (such as "http" or "https"), a domain name, and sometimes the path to a specific file or resource.
URL Encode online tool is used to convert certain characters in a URL to their corresponding hexadecimal representation. This is necessary because some characters, such as spaces and some special characters, are not allowed in URLs. It is also used to easily convert these characters into their encoded form, allowing them to be safely included in a URL.
URL encoding and URL decoding are opposite operations. Encoding takes readable text and replaces every reserved or unsafe character with a percent-encoded triplet - a % sign followed by the two-digit hexadecimal ASCII code of the character (for example a space becomes %20 and an ampersand becomes %26). Decoding does the reverse: it reads those triplets and restores the original characters so the value is human-readable again.
The tool on this page handles the encoding direction - paste raw text and it returns a percent-encoded string that is safe to drop into a URL. When you need to go the other way and expand %20, %26 or %3D back into spaces and symbols, use our URL Decode tool.
RFC 3986, the specification that defines the URI syntax, sorts the characters allowed in a URL into two groups. Reserved characters have a special meaning in a URI and act as delimiters: the general delimiters : / ? # [ ] @ and the sub-delimiters ! $ & ' ( ) * + , ; = . When one of these characters appears as data rather than as a delimiter, it must be percent-encoded so it is not misread.
Unreserved characters never need encoding. They are the uppercase and lowercase letters A-Z and a-z, the digits 0-9, and the four symbols hyphen ( - ), period ( . ), underscore ( _ ) and tilde ( ~ ). The encoder above leaves these unreserved characters untouched and only rewrites the characters that could break a URL. Non-ASCII characters (such as accented letters or emoji) are first converted to their UTF-8 bytes, and each byte is then percent-encoded.
The table below lists the characters people most often need to encode, the hexadecimal value of their ASCII code, and the percent-encoded output this tool produces.
| Character | Name | ASCII (hex) | URL-encoded |
|---|---|---|---|
| (space) | Space | 20 | %20 |
| " | Double quote | 22 | %22 |
| # | Hash / fragment | 23 | %23 |
| $ | Dollar | 24 | %24 |
| % | Percent | 25 | %25 |
| & | Ampersand | 26 | %26 |
| + | Plus | 2B | %2B |
| , | Comma | 2C | %2C |
| / | Slash | 2F | %2F |
| : | Colon | 3A | %3A |
| ; | Semicolon | 3B | %3B |
| = | Equals | 3D | %3D |
| ? | Question mark | 3F | %3F |
| @ | At sign | 40 | %40 |
One character behaves differently depending on context: a space becomes %20 in a URL path or query (the output this tool produces), but it becomes a plus sign ( + ) when data is submitted through an HTML form. That form variant is explained below.
When you need URL encoding inside your own code rather than through this tool, every major language ships a built-in function. The examples below encode a single value for safe use in a query string.
Use encodeURIComponent for individual values - it also encodes / ? : & = - and encodeURI when you want to keep an already-valid URL structure intact. This tool is built on encodeURIComponent.
const raw = "https://example.com/search?q=hello world&lang=en";
const encoded = encodeURIComponent(raw);
// https%3A%2F%2Fexample.com%2Fsearch%3Fq%3Dhello%20world%26lang%3Den
// encodeURI keeps the characters that build a valid URL (: / ? &) intact
encodeURI("https://example.com/my page.html");
// https://example.com/my%20page.htmlPython exposes URL encoding through urllib.parse. Use quote for path-style encoding and quote_plus when you need spaces as plus signs for form data.
from urllib.parse import quote, quote_plus
quote("hello world/?q=a&b") # 'hello%20world/%3Fq%3Da%26b'
quote("hello world", safe="") # 'hello%20world'
quote_plus("hello world") # 'hello+world' (space -> +, for form data)In .NET, HttpUtility.UrlEncode performs form-style encoding (spaces become +), while Uri.EscapeDataString follows RFC 3986 and encodes spaces as %20.
using System;
using System.Web; // HttpUtility lives in System.Web
// Form-style encoding: spaces become "+"
string a = HttpUtility.UrlEncode("hello world"); // "hello+world"
// RFC 3986 encoding: spaces become "%20"
string b = Uri.EscapeDataString("hello world"); // "hello%20world"application/x-www-form-urlencoded is the default MIME type used when an HTML form is submitted with an HTTP POST (or appended to the URL on a GET request). The browser serialises the form into key=value pairs, joins the pairs with an ampersand ( & ), and percent-encodes the keys and values - with one notable difference from standard URL encoding: spaces are written as a plus sign ( + ) instead of %20.
For example, a form with a name field of Ada Lovelace and a role field of R&D lead is encoded as the body below. Note the + for each space and the %26 for the literal ampersand inside the value:
name=Ada+Lovelace&role=R%26D+lead
Because this tool targets URLs rather than form bodies, it encodes spaces as %20. When you specifically need the form-body variant, use the plus-for-space output shown by the quote_plus and HttpUtility.UrlEncode functions above.
Did you find this page helpful?
TestMu AI forEnterprise
Get access to solutions built on Enterprise
grade security, privacy, & compliance