Skip to main content
Premier SEO Services

Text tools

Remove Lines Containing

Delete every line that contains a word or pattern, or keep only those lines, with several terms, any/all matching, whole words and regular expressions.

  • Runs in your browser
  • Free, no sign-up
  • Unlimited use
  • Updated 30 September 2026

Remove Lines Containing

Paste your text — the result updates as you type

How to use the remove lines containing

  1. 1Paste your text into Lines to filter.
  2. 2Type one or more terms into Words or phrases, separated by commas.
  3. 3Choose Remove them or Keep only them, and Any of them or All of them.
  4. 4Switch Show to Removed lines to check what was taken out, then copy the result.

Example

Input
10:01 INFO server started
10:02 WARNING disk 85% full
10:03 ERROR could not reach database
10:04 INFO request served in 120 ms
10:05 error retrying connection
Output
10:01 INFO server started
10:02 WARNING disk 85% full
10:04 INFO request served in 120 ms

Default settings: Words or phrases = error, Remove them, case ignored. Both the “ERROR” and the “error” lines go.

Removing lines that contain a word

A line is removed if the term appears anywhere in it, including inside a longer word: cat matches “category”. Tick Whole words only to match the word on its own, and Match case if capitals matter. The footer shows how many lines were removed and kept.

Keeping only matching lines

Choose Keep only them to do the opposite: everything that doesn't match is removed, like the grep command. With the example log and the terms error, warning, the result is the WARNING line and both error lines. Switch Show to Removed lines to see the lines that were filtered out in either mode.

Several rules with AND/OR

Separate several terms with commas. Any of them matches a line that contains at least one term (OR); All of them matches only lines that contain every term (AND). To use a comma inside a term, type \,.

For “contains A but not B”, run the tool twice: first Keep only them with A, then press Reuse and Remove them with B.

Regex filters for logs and data

Tick Regular expressions to treat each term as a JavaScript regular expression:

PatternMatches lines
^\s*$that are empty or only spaces
^#that start with # (comments)
\b5\d\d\bwith a 5xx status code
^\d{4}-\d\d-\d\dthat start with a date

An invalid pattern shows an error instead of a result. To replace text rather than filter lines, use find and replace.

Is my text private?

This tool runs entirely in your browser. Your text is not uploaded to our servers.

Questions about the remove lines containing

How do I keep only lines that contain a word?

Type the word into Words or phrases and choose Keep only them.

Can I filter with several words?

Yes. Separate them with commas, then choose Any of them to match lines with at least one, or All of them to match lines with every word.

Does it support regular expressions?

Yes. Tick Regular expressions; each comma-separated term is then a pattern. Use the regex tester to try a pattern first.

Last updated 30 September 2026Maintained by Premier SEO Services

Report a problem