Skip to content

View Helpers

stripTags()

stripTags() — returns string

Available in: controller Category: Sanitization Functions

Removes all HTML tags from a string, leaving only the raw text content. Use this when you need to sanitize HTML by completely removing formatting and markup.

NameTypeRequiredDefaultDescription
htmlstringyesThe HTML to remove tag markup from.
encodebooleannotrueEncode URL parameters using EncodeForURL(). Please note that this does not make the string safe for placement in HTML attributes, for that you need to wrap the result in EncodeForHtmlAttribute() or use linkTo(), startFormTag() etc instead.
1. Remove all tags from a string
#stripTags('<strong>Wheels</strong> is a framework for <a href="http://www.adobe.com/products/coldfusion">ColdFusion</a>.')#

Output:
Wheels is a framework for ColdFusion.

2. Sanitize user input
userInput = '<script>alert("xss")</script>Normal text';
#stripTags(userInput)#

Output:
Normal text

3. With encoding
#stripTags('<a href="http://example.com/page?param=value&another=1">Example</a>')#

Output:
Example