JavaScript encodeURI() Function

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP







<!--
main_leaderboard, all: [728,90][970,90][320,50][468,60]
-->



JavaScript encodeURI() Function



JavaScript Global Functions



Example


Encode a URI:



var uri = "my test.asp?name=ståle&car=saab";
var res = encodeURI(uri);

<!--

The result of res will be:



my%20test.asp?name=st%C3%A5le&car=saab
-->
Try it Yourself »


Definition and Usage


The encodeURI() function is used to encode a URI.


This function encodes special characters, except: , / ? : @ & = + $ # (Use
encodeURIComponent() to encode these characters).


Tip: Use the decodeURI() function to
decode an encoded URI.



Browser Support














Function
encodeURI() Yes Yes Yes Yes Yes

Syntax



encodeURI(uri)

Parameter Values





Parameter Description
uri Required. The URI to be encoded

Technical Details




Return Value: A String, representing the encoded URI


❮ JavaScript Global Functions