Remove Lines Containing Specific Text
Log files, exported lists and CSV data often contain lines you do not need. This tool lets you remove lines containing a word, a phrase or a regular expression pattern, or keep only those lines, much like grep and grep -v on the command line.
Example
Input:
2024-05-01 INFO Server started
2024-05-01 DEBUG Cache warmed
2024-05-01 WARN Disk 85% full
2024-05-01 debug Retrying job 7
2024-05-01 ERROR Payment failed
Remove lines containing "DEBUG":
2024-05-01 INFO Server started
2024-05-01 WARN Disk 85% full
2024-05-01 ERROR Payment failed
Because matching ignores case by default, the lowercase “debug” line is removed too. With case sensitivity on, only the uppercase line goes.
Options explained
- Several terms: separate them with commas, as in
DEBUG, INFO. A line is matched if it contains any of the terms. Spaces around the commas are ignored. - Case sensitive: off by default, so “Error” matches “ERROR” and “error”.
- Regular expression: the search box is read as one JavaScript regular expression. Commas are then part of the pattern, not separators; use
|for alternatives, such asWARN|ERROR. An invalid pattern shows an error message instead of a result. - Keep matching lines instead: inverts the filter, so only lines that match stay.
The tool reports how many lines were removed, which is a quick way to count matches.
Matching whole words
A plain search matches text anywhere in the line, so cat also matches “cats” and “concatenate”. To match the word only, enable regular expressions and use word boundaries: \bcat\b. To match at the start of a line, anchor the pattern with ^, for example ^# to drop comment lines from a config file.
Two filtering traps and how to avoid them
Losing a CSV header. If the term also appears in the header row, the header disappears with the data. With Keep matching lines instead and a regular expression you can keep the header explicitly: ^id,|,inactive, keeps the line starting with id, plus every row whose status column is inactive.
Multi-line log entries. The filter works line by line, so removing lines containing ERROR leaves the stack trace lines below each error behind:
2024-05-01 ERROR Payment failed ← removed
at charge (billing.js:42) ← kept
at process (queue.js:17) ← kept
Add a second pattern for the continuation lines, such as ERROR|^\s+at with regular expressions on, or filter on the indentation alone with ^\s.
Useful patterns
^\s*$removes blank lines, though Remove Empty Lines does that directly.^\s*(#|//)removes comment lines from scripts and config files.@example\.com$filters email addresses of one domain from a list.\b(200|304)\bdrops successful requests from an access log so errors stand out.
Related tools
To change text inside lines rather than delete whole lines, use the Text Replacer. To pull one column out of delimited data, try the Delimited Text Extractor.
Privacy
Filtering runs in your browser, so server logs and customer data are not uploaded.