Skip to content

@technobuddha > library > Programming > Escaping

Function: escapeHTML()

ts
function escapeHTML(input: string, options: EscapeHtmlOptions): string;

Defined in: escape-html.ts:26

Escape a string for use in HTML

Parameters

ParameterTypeDescription
inputstringThe string to escape
optionsEscapeHtmlOptionssee EscapeHtmlOptions

Returns

string

Example

typescript
escapeHTML('<div>hello</div>'); // '&lt;div&gt;hello&lt;/div&gt';
escapeHTML('aáΔ😀', { escapeNonASCII: true }); // 'a&#225;&#916;&#128512';