How to Encode an Email in JavaScript for Use in the Query String?

Learn how to encode an email in JavaScript to use it as a GET Param Value

To use an email in the query string component of a URL, you can encode it using the encodeURIComponent() function in JavaScript. This would encode all characters except A-Z a-z 0-9 - _ . ! ~ * ' ( ). For example:

const email = '';
const encodedEmail = encodeURIComponent(email);
const url = `${encodedEmail}`;

console.log(url); //

Hope you found this post useful. It was published . Please show your love and support by sharing this post.