HTML encoding converts special characters to HTML entities, preventing script execution.
Stored XSS occurs when an attacker stores malicious scripts in your database that later execute in users' browsers. By HTML encoding user input, special characters like '' are converted to safe representations ('<' and '>'), preventing scripts from executing. For instance, when displaying user comments on a product page, HTML encoding ensures that any HTML tags are shown as plain text, not executed.
Additional Notes
What is HTML encoding and why is it important in preventing Stored XSS?