Enter or paste your URL in the first text box and click Encode URL button.
The URL will be encoded and appears in the second box below.
URL Encoding is also called as Percent-Encoding. It's because the Unsafe ASCII characters in the URL is encoded to % followed by hexadecimal code.
The browser can recognize the URL in standard ASCII format; especially the URI reserved character set should be used for their intended purpose only. for example the forward slash (⁄) is an URI reserved character to delimit the components in the URL. If you want to use a forward slash (⁄) to represent some thing else in the URL, then you have to encode it with percent-encoding format.
The above URL encoder tools will help you to encode your URL to percent-encoded format. For example, it converts the URL "http://www.mytecbits.com/tools/url/urlencoder" to "http%3a%2f%2fwww.mytecbits.com%2ftools%2furl%2furlencode".
Below is the list of percent-encoed URI reserved characters including few of the commonly used symbols like space, percent, etc...
URI Reserved and Special Characters | Percent-Encoded codes | Description |
---|---|---|
%20 | Space (space is also represented as "+" in URL Encoding) | |
! | %21 | Exclamation mark |
# | %23 | Number Sign (Hash tag) |
$ | %24 | Dollar Sign |
% | %25 | Percent |
& | %26 | Ampersand |
' | %27 | Apostrophe |
( | %28 | Opening Bracket |
) | %29 | Closing Bracket |
* | %2A | Asterisk (Star) |
+ | %2B | Plus Sign |
, | %2C | Comma |
/ | %2F | Forward Slash |
: | %3A | Colon |
; | %3B | Semicolon |
= | %3D | Equal Sign |
? | %3F | Question Sign |
@ | %40 | At Sign |
[ | %5B | Opening Square Bracket |
] | %5D | Closing Square Bracket |
" | %22 | Quotation Mark |
- | %2D | Hyphen (Dash) |
. | %2E | Full Stop |
< | %3C | Lesser Than Sign |
> | %3E | Greater Than Sign |
\ | %5C | Backward Slash |
_ | %5F | Underscore |
| | %7C | Sipe (Vertical Bar) |
.Net provides two options to encode url. You can use either HttpServerUtility.UrlEncode method or the HttpUtil.UrlEncode method in the System.Web namespace. Both these UrlEncode methods give the same result.
using System.Web.Mvc; namespace SampleCodeSolution.Controllers { public class HomeController : Controller { public ActionResult Contact() { string sUrl; string strQueryStringUrl = "http://www.mytecbits.com/tools/url/urlencoder"; sUrl = "~/NextPage?url=" + Server.UrlEncode(strQueryStringUrl); return View(sUrl); } } }
Java provides URLEncoder class to encode url query string. The URLEncoder class has the method encode which takes in the string to be encoded and returns the percent encoded string.
import java.net.URLEncoder; public class MTBSampleEncode { public static void main(String args[]) { try { String urlQueryString = "http://www.mytecbits.com/tools/url/urlencoder"; String encodedQueryString = URLEncoder.encode(urlQueryString, "UTF-8"); System.out.println("Encoded URL Query String: " + encodedQueryString); } catch (UnsupportedEncodingException e) { System.err.println(e); } } }
JavaProvides provides two functions encodeURI() and encpdeUTIComponent() to encode the url.
The encodeURI() function encodes all the special charactors in an URI except / , @ : = & $ + # ? which takes in the string to be encoded and returns the percent encoded string.
<script> var urlToEncode = "http://www.mytecbits.com/tools/url/urlencoder?Encode this ' text"; var encodedUrl = encodeURI(urlToEncode); alert(encodedUrl); </script>
The result of above encoding will be http://www.mytecbits.com/tools/url/urlencoder?Encode%20this%20'%20text
encpdeUTIComponent() function encodes all the special charactors including the once which are left out by encodeURI().
<script> var urlToEncode = "http://www.mytecbits.com/tools/url/urlencoder?Encode this ' text"; var encodedUrl = encodeURIComponent(urlToEncode); alert(encodedUrl); </script>
The result of above encoding will be http%3A%2F%2Fwww.mytecbits.com%2Ftools%2Furl%2Furlencoder%3FEncode%20this%20'%20text
Page Last Modified On: Jul 23, 2021
Disclaimer: We took every effort to provide higher level of accuracy in the calculators, converters and tools we have added to www.MyTecBits.com Tools section. But, we cannot give any guarantee or can be held responsible for any errors, defects, faults or mistakes in any of the calculators, converters or tools. Please see detailed terms of use and liability disclaimer in Terms of Use Page.