FormatterHQ

Remove Lines Containing

Delete every line that contains a word, phrase or regular expression, or flip the filter and keep only the matching lines.

Input TEXT
Output TEXT
Ready.

How to use the Remove Lines Containing

  1. Paste the text or log you want to filter.
  2. Enter the word or phrase to look for; separate several terms with commas.
  3. Choose case sensitivity, turn on regular expressions if needed, and decide whether matching lines are removed or kept.
  4. Copy the filtered text.

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 as WARN|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)\b drops 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.

Frequently asked questions

How do I remove lines that contain one of several words?
Type the words separated by commas, for example “DEBUG, TRACE”. Any line containing at least one of them is removed. In regular-expression mode, use DEBUG|TRACE instead.
How do I keep only the lines that contain a word?
Turn on the option to keep matching lines. The filter is then inverted and works like grep, returning only lines that contain your term.
Why were lines with a longer word removed as well?
Plain search matches text anywhere in a line, so “cat” also matches “category”. Enable regular expressions and search for \bcat\b to match the whole word only.
Is the search case-sensitive?
Not by default. Turn on case sensitivity when capitalization matters, for example to remove “DEBUG” lines but keep ones that mention “debug” in a message.

Last updated October 3, 2026

Related tools