Remove Lines Containing TextFilter by Keyword or Regex

Paste your text, list the words you want gone, and get back only the lines that don't contain them. You can also keep matching lines instead.

Your input is never sent anywhere.

Details

Input text

A line matches if it contains any of these.

Options

Result

0 of 0 lines

Delete lines that match, or keep only the ones that do

This tool checks every line of your text against the words or patterns you enter. In Remove matching lines mode, any line that contains a match is deleted. In Keep matching lines mode, only those lines are kept.

Enter one entry per line to filter on several words at once. A line counts as a match if it contains any entry. Turn on Use regex when plain text is not enough, for example to match lines that start with #.

Cleanup options run after the filter: remove blank lines, remove duplicate lines, and trim spaces. Everything runs in your browser.

Where line filtering saves time

Server and application logs

Drop DEBUG and INFO lines so only ERROR and WARN remain, or keep only the lines that mention one request ID.

Email, URL, and keyword lists

Remove every address that contains a domain, or every URL that contains a path such as /tag/, before you import the list.

Config files and source code

Strip comment lines by removing lines that start with # or //, using a regex pattern.

Copied text with unwanted lines

Delete lines such as ads, page numbers, or headers that repeat through text you copied from a web page or document.

How to remove lines in 3 steps

  1. Paste your text into the Input text box.
  2. Enter the words or patterns to match, one per line, and choose Remove matching lines or Keep matching lines.
  3. Check the result, then click Copy or Download .txt.

Note: The result updates as you type, so you can adjust the match list and options until the output looks right.

How matching works

  • Several entries: a line matches if it contains at least one entry. There is no AND option. To require two words, filter once, paste the result back into the input, and filter again.
  • Partial matches: in plain mode an entry matches anywhere in a line. The entry in matches info and index. Use a longer entry such as [INFO], or a regex with \b around the word.
  • Spaces in entries: spaces you type in the match box count as part of the entry. Only completely empty entry lines are ignored.
  • Order of steps: trimming happens first, then the keyword filter, then blank-line removal, then duplicate removal. With Trim each line on, matching is done on the trimmed line.
  • Regex flavor: patterns use JavaScript syntax and are tested against one line at a time.

Example entries for common cleanup jobs

Paste these into the match box. The Regex column tells you whether to turn on Use regex.

GoalModeEntriesRegex
Hide debug noise in a logRemove matching linesDEBUG, INFO (one per line)Off
Show only errorsKeep matching linesERROR, WARN (one per line)Off
Strip comment linesRemove matching lines^\s*(#|//)On
Remove emails from one domainRemove matching lines@example.comOff
Remove URLs under a pathRemove matching lines/blog/Off
Keep lines that start with a digitKeep matching lines^\dOn
Remove lines that mention a word, any capitalizationRemove matching linesdraft (with Ignore case on)Off

Remove matching lines does what grep -v does, and Keep matching lines does what grep does. You get the same result in the browser, with no command line.

grep -v, regex, and other ways to filter lines

How this tool compares with editor and command-line approaches, and when each fits.

Doing the same thing in Notepad++ or a command line

Editors and shells can do this, but each needs a few steps: a Find and Replace pattern in Notepad++, or grep -v or sed '/text/d' in a terminal. This page does the same filtering without installing anything.

When plain text is enough and when you need regex

Plain mode is the safer choice for simple words, because characters such as . and ( are matched as they are. Turn on regex for patterns, like lines that start with a symbol or that end with a number.

Filtering in more than one pass

To remove lines that contain either of two words, enter both on separate lines. To keep only lines that contain two words together, run Keep matching lines once, paste the output back into the input, and run it again with the second word.

Why too many or too few lines disappear

A short entry removes lines you wanted

Entering a short string such as id or in matches inside longer words, so lines with info or index are removed too.

💡 See the solution▼
Use a longer, more specific entry such as [INFO], or turn on Use regex and wrap the word in word boundaries, like \bid\b.

Lines with different capitalization slip through

The match is case-sensitive by default, so ERROR does not match Error or error, and those lines stay in the result.

💡 See the solution▼
Turn on Ignore case, or add an entry for each spelling you need.

Special characters don't match as expected

With Use regex on, characters such as . ( ) [ ] + ? have special meaning, so a pattern like (test) or 1.5 may not match what you typed.

💡 See the solution▼
Turn Use regex off for plain text, or escape the character with a backslash, as in 1\.5.

Blank lines are missing from the result

Remove blank lines is on by default, so empty lines in your input are dropped even when no entry matches them.

💡 See the solution▼
Turn Remove blank lines off if you need the original spacing.

Questions about removing and keeping lines

Q.How do I remove all lines that contain a certain word?

Q.

A. Paste your text, type the word into the text-to-match box, and leave the mode on Remove matching lines. Every line that contains the word is dropped, and the rest appear in the result box right away.

Q.Can I remove lines that match several words at once?

Q.

A. Yes. Put one word or phrase on each line of the match box. A line counts as a match if it contains any of them, so ERROR on one line and WARN on the next removes lines with either word.

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

Q.

A. Switch the mode to Keep matching lines. The result then holds only the lines that contain at least one of your entries. This works like grep, and Remove matching lines works like grep -v.

Q.Can I remove lines that do not contain a word?

Q.

A. Yes. Use Keep matching lines with the word you want to keep. Every line without the word is dropped.

Q.Does it use regular expressions?

Q.

A. Only if you turn on Use regex. It is off by default, so characters such as . * and ( are matched as plain text. With regex on, each line of the match box is treated as one JavaScript regular expression, and a line matches if any expression finds a match in it. An invalid pattern shows an error and the keyword filter is skipped.

Q.Is the match case-sensitive?

Q.

A. Yes by default, so Error and error are different. Turn on Ignore case to match both.

Q.What happens if the match box is empty?

Q.

A. No lines are filtered by keyword. The other options, such as Remove blank lines and Remove duplicates, still apply.

Q.Is my text uploaded anywhere?

Q.

A. No. The filtering runs in your browser with JavaScript, and nothing is sent to a server. The text stays in the page while it is open.

Q.How do I save the result?

Q.

A. Click Copy to put the result on your clipboard, or Download .txt to save it as a plain text file named filtered-lines.txt.

User Feedback & Request

Your feedback
makes this tool better.

Tell us which features you'd like, what should be fixed, or which new tool you'd like to see. An engineer reads every submission and uses it to guide development.

Send feedback