Syntax
Description
Determines which HTML elements should be completely removed from the output (converted to an empty string). Both the element and its contents are removed. By default, Turndown does not remove any elements.Parameters
Specifies which elements to remove:
- String: A single tag name (e.g.,
'del') - Array: Multiple tag names (e.g.,
['script', 'style']) - Function: Custom filter function
(node, options) => boolean
Returns
Returns the TurndownService instance for method chaining
Examples
Remove Single Element
Remove Multiple Elements
Remove with Custom Filter
Remove Comments or Metadata
Chaining Remove Calls
Behavior Details
Element and Contents Removed
Both the element and all its contents are removed:Whitespace Handling
Removing elements doesn’t leave extra whitespace:Notes
- Returns the instance to enable method chaining
- Can be called multiple times; newer filters take precedence
- Remove filters are overridden by keep filters, CommonMark rules, and added rules
- To remove elements normally handled by those rules, add a custom rule instead
- Removes both the element tags and all content inside them
- Use
keep()if you want to preserve the HTML but not convert it