Remove lines containing

Deletes — or keeps — every line that matches a word or pattern.

Type a word, choose how it should match, and either delete every line containing it or throw away everything else. The tool tells you how many lines it removed, which is the quickest way to check you filtered what you thought you did.

Five ways to match

Most tools in this category only offer "contains", and that is the source of a lot of quiet damage. Filtering a list of files for test with a plain contains match also deletes latest.log and protest.txt. The modes here exist so you can be precise.

Matching ignores case unless you tick the box, because most of the time you are looking for a word rather than a specific capitalisation of it.

Remove or keep — the same operation, inverted

These are two sides of one filter, and having both matters. "Remove matching" is how you strip noise: debug lines, comments, a supplier you no longer stock. "Keep only matching" is how you extract signal: every line mentioning an error code, every row for one region, every URL containing a path.

A pattern that is hard to write as "remove everything except X" is often trivial as "keep only X", and vice versa. If you find yourself building a monstrous regex, try the other button.

Typical uses

Doing it without this tool

Notepad++: Search → "Find all in current document", then use "Bookmark all lines" from the Mark dialog and Search → Bookmark → "Remove bookmarked lines". It works and almost nobody remembers the sequence.

VS Code: no built-in filter. The common workaround is Ctrl+Shift+L to select all occurrences, then Home, Shift+Down to select whole lines and delete — which fails on lines with more than one match.

Excel: a helper column with =ISNUMBER(SEARCH("word",A1)), then filter and delete the visible rows.

Command line: this is what grep is. grep -v word file.txt removes matching lines, grep word file.txt keeps them, -i ignores case and -w matches whole words. If a terminal is open, that is faster than any web page.

Try:
0Words
0Characters
0No spaces
0Sentences
0Paragraphs
0Lines
0Pages
0Reading
0Speaking

Runs entirely in your browser. Your text is never uploaded — open DevTools, Network tab, and you will see zero requests while you use this tool.

How to use it

  1. Paste your text into the box.
  2. Type the word or pattern you want to match.
  3. Choose the match mode — use "Whole word" to avoid matching longer words that contain yours.
  4. Press "Remove matching lines" to delete them, or "Keep only matching lines" to discard everything else.

Related tools

Join linesMerges every line into a single line with the separator you choose.Add line numbersNumbers every line, in the format you choose — and removes numbering too.Cut charactersCuts a fixed number of characters from the start or end of every line.Split into chunksBreaks long text into equal parts by characters, words or lines.Small capsSmall capital letters that paste anywhere plain text goes.PDF text breaksThe file has no paragraphs to give you. Here is what it does have, and how to…Username generatorReadable names built from real words. No xX_ padding, no forced digits.

See all text tools →

Frequently asked questions

How do I stop it matching longer words?

Choose the "Whole word" mode. Searching for cat then matches cat but not catalogue, because the word has to be surrounded by non-letter characters.

Is the match case sensitive?

Not by default. Tick "Case sensitive" if the capitalisation matters, for example when filtering for an all-caps log level like ERROR while ignoring the word error in messages.

Can I remove lines that do NOT contain a word?

Yes — that is the "Keep only matching lines" button, which is the same filter inverted. Everything without a match is discarded.

Does it support regular expressions?

Yes, choose "Regular expression" in the match dropdown. Standard JavaScript syntax applies, so ^ and $ anchor to the line and | means or.

How do I know it removed the right lines?

After each run the message under the buttons reports how many lines were removed. If the number is unexpected, press Undo and adjust the match mode.