strip

Remove all leading and trailing whitespace characters from both ends of a string.

Syntax

{{ string | strip }}

Example

{% assign text = " Clean Both Sides " %}[{{ text | strip }}]

Output

[Clean Both Sides]

The strip filter removes all leading and trailing whitespace, tab, and newline characters from both ends of a string, preserving internal word spacing perfectly.

On keyword combination landing pages, strip sanitizes individual items parsed by split from human-entered spreadsheets where spaces frequently follow commas. For example: {% for item in row.tags | split: ',' %}<span>{{ item | strip }}</span>{% endfor %}. This ensures HTML badge elements have neat padding and no accidental margin offsets.

Try this syntax in the editor.