JavaScript encodeURIComponent

encodes a URI component.

Function

encodeURIComponent ( uriComponent )

Parameters

uriComponent - Any type of the following object: number, string, boolean, undefined, null, which before encoing, it gets converted to string.
Characters not escaped: A-Z, a-z, 0-9, -, _, ., !, ~, *, ', (, )

Return value

An encoded URI component.

Example

const a = encodeURIComponent(
  "https://urlencoder.net/javascript-encodeuricomponent"
)

Output

https%3A%2F%2Furlencoder.net%2Fjavascript-encodeuricomponent

Github

See also: