Client-side encoding is a security mechanism used to prevent attacks like Cross-Site Scripting (XSS) by encoding user inputs before rendering them in the browser. Encoding ensures that special characters (like <, >, &, " ) are treated as text rather than executable code.