Filter Lines Containing TextKeep or Remove with Regex

Paste text or a log, type what to look for, and keep only the lines that match, or remove them. Supports regex, multiple terms, and context lines.

Your input is never sent anywhere.

Details
0 lines
Regex presets

Result0 of 0 lines

Paste some text to get started

A grep-style line filter that runs in your browser

The tool tests every line of your text against the terms you type and shows only the lines that pass. Choose Keep to see the matching lines, or Remove to see everything except them.

You can enter several terms and require any or all of them, switch on regular expressions, match whole words, and add lines of context before and after each match. The result can show the original line numbers.

It covers the common uses of the grep command without a terminal, and the filtering happens on your device.

What people filter lines for

Log files

Keep the lines with ERROR, WARN, a status code, or one IP address. Add context lines to see what happened just before and after.

Lists and exports

Cut a long list down to the rows that mention one product, one city, or one email domain, and download the result as a text file.

Cleaning out noise

Switch to Remove to drop test entries, cancelled orders, comment lines, or any other lines you do not want.

Code and config files

Find every line that mentions a function, a TODO, or a setting name, with line numbers so you can jump to it in your editor.

How to keep or remove matching lines in 4 steps

  1. Paste your text into Input text.
  2. Type a term in Search terms. Add more terms on new lines, and choose Any term or All terms.
  3. Choose Keep or Remove. Turn on regex, whole word, context lines, or line numbers if you need them.
  4. Check the count above the result, then click Copy lines or Download .txt.

Note: There is no run button. The result updates each time you change the text, a term, or a setting, and your pasted text itself is never changed.

How matching works

  • Terms: each non-empty line in Search terms is one term. Any term keeps a line that contains at least one of them. All terms keeps a line only if it contains every one. With no terms, nothing is filtered, but the other settings still apply.
  • Plain text vs regex: with Use regex off, every character is searched for literally. With it on, each term is a JavaScript regular expression tested against one line at a time. An invalid pattern shows an error instead of a result.
  • Whole word: available in plain text mode only. The characters before and after the match must not be letters A to Z, digits, or underscores, so accented letters count as word breaks. In regex mode, use \b in your pattern instead.
  • Order of steps: lines are trimmed first if that is on, blank lines are dropped next if that is on, and then the terms are applied. Duplicates are removed from the lines that remain.
  • Context lines: they apply when you keep matching lines. Groups that are not next to each other are separated by a line with two dashes, and that line is included when you copy or download.

Search examples to copy

What to type and which settings to use for common jobs.

To findWhat to typeSettings
Error and warning lines in a logERROR (new line) WARNAny term
Lines about one user and one actionuser=42 (new line) loginAll terms
Everything logged on one day2026-10-28Plain text
Gmail addresses in a list@gmail.comPlain text, so the dot is literal
The word cat but not categorycatWhole word
Lines that start with a number^\dUse regex
Lines containing an IPv4-style address\b(?:\d{1,3}\.){3}\d{1,3}\bUse regex; it checks the shape, not whether each part is 255 or lower
Everything except comment lines^\s*(?:#|//)Use regex and Remove
An error with the 2 lines around itERRORContext lines set to 2

Regex presets. The preset buttons next to the search box fill in a regex for emails, URLs, IPv4-style addresses, lines of digits only, and comment lines. They are simple patterns meant for quick filtering, not strict validation.

Private by design. The filtering runs in your browser, and the tool has no upload step.

Filtering logs, lists, and exports line by line

How to get useful results from a line filter, and how its settings map to grep.

Reading a log without losing the story around an error

Keeping only lines with ERROR shows what failed, but not what led to it. Set Context lines to 2 or 3 to bring in the lines before and after each match, and turn on Line numbers so you can find the same spot in the original file.
A stack trace is spread over several lines, and only the first one usually contains the keyword. Context lines are the quickest way to keep the rest of it.

Cleaning up lists and exported data

Use Remove to drop rows that contain words like test or cancelled, then turn on Trim whitespace and Remove duplicates to tidy what is left. The count above the result shows how many lines survived.
The tool works on whole lines, so it filters rows, not columns. A cell in a CSV file that contains a line break spans two lines in the text and will be filtered as two separate lines.

If you are used to grep

-i is the default here, and Match case turns it off. -v is Remove, -w is Whole word, -n is Line numbers, -C 2 is Context lines set to 2, and -e a -e b is two terms with Any term. -E is Use regex.
The pattern syntax is JavaScript, not POSIX, so \d and \b work, but classes such as [[:digit:]] do not.

Common filtering mistakes

A dot or question mark matches almost everything

With Use regex on, a dot matches any character and a question mark makes the previous character optional. A term like gmail.com then matches lines you did not mean to find, and a lone ? can match every line.

💡 See the solution▼
Turn Use regex off for ordinary text, or put a backslash before the special character, as in gmail\.com. With regex off, every character is searched for literally.

Losing the lines around an error

You keep only the lines that contain ERROR, and the request line before it and the rest of the stack trace after it are gone, so the cause is hard to see.

💡 See the solution▼
Set Context lines to 2 or 3. The surrounding lines are added to each match, and the line numbers show where each group sits in the original text.

A short term matches longer words

Searching for cat also finds category and concatenate, and Remove with the term test also deletes lines that contain latest.

💡 See the solution▼
Turn on Whole word in plain text mode, or use a regex with word boundaries such as \bcat\b. Compare the line count before and after, and look through the result before you copy it.

Deleting more than intended with Remove

A broad term in Remove mode takes out lines you wanted to keep, and you may not notice until the output is already pasted somewhere else.

💡 See the solution▼
Check the count in the badge first, then scan the result. Your pasted text stays in the input box, so you can change the term and try again without pasting it twice.

Line filter FAQ

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

Q.

A. Paste your text, type the word in Search terms, and leave Matching lines set to Keep. The result shows only the lines that contain the word, and the badge tells you how many of the input lines remain. Copy lines or Download .txt saves exactly what is shown.

Q.How do I delete every line that contains a word?

Q.

A. Set Matching lines to Remove. The result then shows every line that does not match any of your terms. Your pasted text is not changed, so you can switch back to Keep at any time.

Q.Can I search for more than one word at once?

Q.

A. Yes. Put each term on its own line in Search terms. With Any term, a line is kept if it contains at least one of them, which works like OR. With All terms, a line is kept only if it contains every one of them, which works like AND. Empty lines in the terms box are ignored.

Q.Is the search case sensitive?

Q.

A. No, capital letters are ignored by default, so error also finds ERROR and Error. Turn on Match case if you need an exact match.

Q.How do I use a regular expression, and how do I search for a dot or a question mark?

Q.

A. Turn on Use regex. Each line in Search terms is then read as a JavaScript regular expression, and it is tested against each input line separately, so ^ and $ mean the start and end of a line. With regex on, characters such as . ? * ( [ have special meaning, so put a backslash in front to search for them literally, for example gmail\.com. With regex off, every character is searched for literally.

Q.How do I see the lines around each match, like grep -C?

Q.

A. Choose a number under Context lines around each match. The tool then adds that many lines before and after every match, and puts a line with two dashes between groups that are not next to each other. Context lines work when you keep matching lines and have at least one search term. While they are on, Remove duplicates is switched off so the surrounding lines stay in order.

Q.Can I keep the original line numbers?

Q.

A. Yes. Turn on Line numbers and each result line starts with its position in the text you pasted, such as 128: followed by the line. The numbers still count blank lines you skipped, and the copied or downloaded text includes them.

Q.What do Trim whitespace, Skip blank lines, and Remove duplicates do?

Q.

A. Trim whitespace removes spaces and tabs from both ends of every line before matching, so the matches and the output are trimmed. Skip blank lines drops lines that are empty or contain only whitespace, in both Keep and Remove mode. Remove duplicates keeps the first copy of each identical line in the result, and the comparison is case sensitive.

Q.Does it work with text from Windows, Mac, or Linux?

Q.

A. Yes. Lines are split at Windows (CRLF), old Mac (CR), and Unix (LF) line endings, and one line break at the very end of the text does not add an empty line. Patterns that end with $ therefore match the end of the visible text on every line.

Q.Is my text uploaded anywhere?

Q.

A. No. The filtering runs as JavaScript in your browser and the tool has no upload step, so logs and lists stay on your device. The tool sets no size limit, but a very large paste can be slow on an older device, and a badly written regular expression can make the page freeze until it finishes.

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