Keep Lines Containing A Certain Words
Keep Lines Containing A Certain Words
Keep Lines Containing A Certain Words keeps only the lines that contain at least one of the words you type. Paste your text, enter your words and copy the result. It is free and runs in your browser.
Keep Lines that Contain Certain Words Tool
Please note: use words and numbers. A line is kept if it contains at least one of them.
Keep Lines Example
Michael ran slow. We ate pizza. He loves cheese. I love to run quick.
We ate pizza. I love to run quick.
Bookmark: press Ctrl+D (Windows) or Cmd+D (Mac) to save this tool.
What does Keep Lines Containing A Certain Words do?
This tool keeps the lines that contain at least one of the words you type and removes all other lines. Type one word or text on each line of the words box.
By default the words match anywhere in a line, so run also keeps a line with running, and capital letters do not matter. Tick Whole words only to match complete words, and Match case to match capitals exactly. Empty lines are removed because they contain nothing.
Use it to pull the lines you need out of a log, a list of names, an export or any long text, when you are looking for more than one word at once.
Keep lines containing certain words examples
Each example shows the words used, one per line in the words box. Capitals are ignored unless Match case is on.
| Setting | Before | After |
|---|---|---|
| Words: ate, run | Michael ran slow. We ate pizza. He loves cheese. I love to run quick. | We ate pizza. I love to run quick. |
| One word: error | ok: saved error: disk full ok: sent error: timeout | error: disk full error: timeout |
| Words: cat, dog (any one) | Cat food dog bowl bird seed | Cat food dog bowl |
| Inside words (run) | running late runway walk | running late runway |
| Whole words only (run) | running late run home runway | run home |
| Match case on (Cat) | Cat food cat toy dog bowl | Cat food |
How to keep lines containing certain words
- 1Add your text
Type or paste your lines into the box, or import a text file. - 2Enter your words
Type the words you want, one per line. Tick Match case or Whole words only if you need them. - 3Click Keep Lines
Only the lines that contain at least one of your words stay. Use Undo if you change your mind. - 4Copy it
Click Copy and paste the result where you need it.
When to keep lines containing words
Good for
Finding the lines you need in a log, a list of names or an export when you are looking for several words at once, and removing everything else in one step.
Check first
A line is kept if it has any one of the words, not all of them. Words match inside other words unless you tick Whole words only, so cat also keeps category. Lines that do not match are deleted from the box. Use Undo right after if the result is not what you wanted.
Other tools
To search for just one word, try Keep Lines Containing A Certain Word. To delete the matching lines instead, try Remove Lines With Certain Words. To get rid of blank lines, try Remove Empty Lines.
Keep lines containing certain words FAQ
What does the Keep Lines Containing A Certain Words tool do?
It keeps only the lines that contain at least one of the words you enter and removes all other lines.
How do I keep lines containing certain words?
Type or paste your text, enter your words in the words box with one on each line, and click Keep Lines. The result replaces the text in the box. Click Copy to use it, or Undo to go back.
Must a line contain all the words?
No. A line is kept if it contains any one of the words. The example keeps We ate pizza. for ate and I love to run quick. for run.
Does it match whole words only?
Not by default. Words match anywhere in a line, so run also keeps a line with running. Tick Whole words only to match complete words.
Does it care about capital letters?
Not by default, so Sun, SUN and sun all match. Tick Match case if you want capitals to match exactly.
What happens to empty lines?
They are removed, because an empty line does not contain any of your words. Blank lines in the words box are ignored.
What if no line contains my words?
The tool shows a message and leaves your text as it is, so nothing is deleted by mistake.
Is this tool free and is my text private?
Yes. It is free, needs no account and runs in your browser, so your text is not uploaded to a server.
Looking for more text tools?
Browse Modify ToolsLast updated: 31 October 2026
