Sanitize HTML to prevent XSS and Javascript injection

To give a little background on when this can/should be used, when would you recommend using this? For all text input by a user? Does it only apply to HTML input?

I’m familiar with these concepts and security implications but unsure about specific recommendations for Anvil.