Home > widget-integration > FilterValidationHelper > stripHtml

FilterValidationHelper.stripHtml() method

Sanitizes a string by removing all HTML tags.

Strips all HTML markup, leaving only text content. Useful for displaying user-generated content safely.

Signature:

stripHtml(html: string): string;

Parameters

Parameter

Type

Description

html

string

The HTML string to sanitize. Can contain any HTML markup.

Returns:

string

Plain text without HTML tags. Empty string if input is empty.

Example

Strip HTML from user input:

const plainText = this.validationHelper.stripHtml(userInput);
element.textContent = plainText;