Menu

Remove Lines Containing a Word or Text

Type the text to look for and every line that contains it disappears from the result. Switch to "Keep only them" to filter the other way and keep just the matching lines.

0 words 0 characters 0 lines

Lines that match

Continue with this text: Remove duplicatesSort linesFind and replace

Your text stays in your browser: nothing is uploaded or stored on a server.

How to remove lines containing text

  1. Paste your text into Your text, or use Open file for a .txt, .csv or .log file. Example loads a short mailing list.
  2. Type what you are looking for in Text to look for. For several words, separate them with commas.
  3. Under Lines that match, choose Remove them to delete the matching lines, or Keep only them to delete everything else.
  4. Tick Case-sensitive, Whole line must match or Regular expression if you need a stricter match.
  5. The result updates as you type. The status line shows how many lines matched; Copy, Download .txt or Use as input to run another tool on it.

What each option changes

Option Off (default) On
Case-sensitive error matches error, Error and ERROR error matches only error
Whole line must match The text can be anywhere in the line: cat matches catalog The whole line must equal the text: cat matches cat and Cat (spaces at both ends are ignored), not catalog
Regular expression The query is plain text: . is a period, | is a pipe The query is a JavaScript regular expression: . is any character, | means “or”

Whole line must match works with both kinds of query. With plain text, each comma-separated term is compared with the whole line, so a, b matches the lines a and b (write a\, b for a line that reads a, b). With Regular expression, the pattern must match the entire line, like grep -x: cat matches cat but not catalog. In regex mode spaces at the ends of the line are not ignored, so cat does not match Cat ; write \s*cat\s* if they may be there.

Exactly how lines are matched

  • A line is everything between two line breaks. Windows (CRLF), old Mac (CR) and Unix (LF) breaks are all recognized, and the result always uses LF.
  • Contains means the text appears anywhere in the line, inside other words too: cat matches concatenate. Use the regex \bcat\b for the word on its own.
  • Several terms: unsubscribe, bounced is two terms and a line is matched if it contains either one. Spaces next to a comma are ignored; all other spaces are part of the search, also at the start or end of the query: bar, zzz searches for bar (with a leading space, so it matches foo bar but not foobar) and zzz.
  • Commas: write \, to search for a literal comma inside a term (Smith\, John). A query made only of commas, such as ,, is searched as typed and matches every line that contains a comma.
  • Empty lines never contain a word, so in Remove mode they stay, and in Keep mode they go. To remove blank lines, use the regex ^\s*$ or the remove empty lines tool.
  • Order and duplicates: the remaining lines keep their original order, and identical lines are all kept or all removed. Run the duplicate line remover afterwards if you need each line once.
  • Accents and emoji are compared as typed: cafe does not match café. Emoji can be searched like any other character. When case is ignored, the Turkish capital İ counts as i, so istanbul matches İstanbul.
  • An empty query removes no lines.
  • An invalid regular expression, such as an unclosed (, shows a message like “Invalid regular expression: unterminated group” instead of a result. Escapes that grep and Notepad++ accept but JavaScript’s Unicode mode rejects, such as \:, \-, \# or \@, are read as the plain character.

Worked examples

The built-in example, with Text to look for set to unsubscribe, bounced and Remove them:

Before                              After
[email protected]                    [email protected]
bounced: [email protected]            [email protected]
[email protected]                     [email protected]
unsubscribe: [email protected]
[email protected]

A server log with the query debug, trace. Case does not matter, so both DEBUG and debug go:

2026-10-21 09:00:01 INFO  Server started
2026-10-21 09:00:02 DEBUG Loading config
2026-10-21 09:00:05 WARN  Disk 85% full
2026-10-21 09:00:07 debug Cache warm
2026-10-21 09:01:10 ERROR Payment failed

becomes

2026-10-21 09:00:01 INFO  Server started
2026-10-21 09:00:05 WARN  Disk 85% full
2026-10-21 09:01:10 ERROR Payment failed

With Case-sensitive ticked and the query DEBUG, only the 09:00:02 line is removed and the lowercase debug line stays. With Regular expression, WARN|ERROR and Keep only them, the result is just the WARN and ERROR lines.

Plain text and a regex give different results for keyword lists:

Query Mode Lines removed from running shoes, free running shoes, shoes, nike running shoes free shipping, freestyle shoes
free Contains free running shoes, nike running shoes free shipping, freestyle shoes
\bfree\b Regular expression free running shoes, nike running shoes free shipping

With Whole line must match and the query n/a, the lines N/A and n/a (with trailing spaces) are removed, while N/A pending stays because it has more text.

When people need it

  • Cleaning a mailing list: remove addresses marked bounced or unsubscribe in an export, or keep only one domain with @example.com and Keep mode. To pull addresses out of running text first, use the email extractor.
  • Reading logs: drop DEBUG and health-check lines, or keep only WARN and ERROR lines.
  • SEO keyword lists: remove negative keywords such as free, jobs or a competitor’s brand from a keyword export, then sort the lines.
  • URL lists: remove tag pages and tracking links from a crawl with /tag/, utm_.
  • Config and code: remove comment lines with the regex ^\s*# (lines starting with #, indented or not), while lines such as code # x stay.

To change text inside the lines instead of deleting whole lines, use find and replace.

The same job in grep and Notepad++

On Linux and macOS, grep -v 'text' file.txt prints the lines that do not match, which is this tool’s Remove mode; plain grep is Keep mode. -i ignores case (this tool’s default), -x matches the whole line and -F treats the pattern as plain text. Note that grep is case-sensitive unless you add -i, while this tool is case-insensitive unless you tick Case-sensitive.

In Notepad++, open Search > Mark, type the text, tick Bookmark line and click Mark All. Then choose Search > Bookmark > Remove Bookmarked Lines to delete those lines, or Remove Non-Bookmarked Lines to keep only them. This page needs no install and gives the same result for text copied from any program.

Questions

How do I remove lines containing a specific word?

Paste your text, type the word in "Text to look for" and leave "Remove them" selected. Every line that contains the word anywhere, in any case, is removed. To match only the whole word (so "cat" does not remove "catalog"), tick Regular expression and type \bcat\b.

Can I remove lines containing any of several words?

Yes. Separate the words with commas, for example debug, trace. A line is removed if it contains at least one of them. Spaces around each comma are ignored.

How do I keep only the lines that contain a word?

Choose "Keep only them" under "Lines that match". The tool then works like a filter, the same as grep without -v on the command line, and returns only the matching lines in their original order.

How do I remove lines that contain a comma?

Type , on its own; a query made only of commas is searched as typed. Inside a longer query a comma separates terms, so write \, for a literal comma, for example Smith\, John to match the text Smith, John rather than Smith or John.

Is the search case-sensitive?

Not by default; "error" also matches "Error" and "ERROR". Tick Case-sensitive to match the exact capitalization. The option applies to plain text, whole-line and regular-expression searches.

How do I do the same with grep on Linux or macOS?

On the command line, grep -v 'text' file.txt prints the lines that do not contain the text, -i ignores case and -x matches the whole line. This page does the same in the browser when you are not at a terminal or the text is not in a file.

Is my text uploaded anywhere?

No. The filtering runs in your browser. The text stays in this browser tab so it is still there if you open another tool, and it is gone when you close the tab.