Keep Lines Containing A Certain Words

Free online text tool

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

0Character Count
0Character Count (without spaces)
0Word Count
0Sentence Count
0Paragraph Count
0Line Count

Please note: use words and numbers. A line is kept if it contains at least one of them.

Keep Lines Example

Before (keep lines containing ate or run)
Michael ran slow.
We ate pizza.
He loves cheese.
I love to run quick.
After
We ate pizza.
I love to run quick.

Bookmark: press Ctrl+D (Windows) or Cmd+D (Mac) to save this tool.

Suggest a New ToolProvide Feedback on 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.

SettingBeforeAfter
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

  1. 1
    Add your text
    Type or paste your lines into the box, or import a text file.
  2. 2
    Enter your words
    Type the words you want, one per line. Tick Match case or Whole words only if you need them.
  3. 3
    Click Keep Lines
    Only the lines that contain at least one of your words stay. Use Undo if you change your mind.
  4. 4
    Copy 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 Tools

Last updated: 31 October 2026

Similar Posts

  • Capitalize Words

    Home / Basic Tools / Capitalize Words Free online text tool Capitalize Words Capitalize Words changes the first letter of every word to a capital letter, so hello world becomes Hello World. Type or paste your text below, click the button and copy the result. It is free and runs in your browser. Capitalize Words…

  • Remove Duplicate Lines

    Home / Remove Tools / Remove Duplicate Lines Free online text tool Remove Duplicate Lines Remove Duplicate Lines keeps only the unique lines of your text and removes the repeated ones. Paste your lines, click the button and copy the result. It is free and runs in your browser. Remove Duplicate Lines Tool Import From…

  • Commas Between Numbers

    Home / Modify Tools / Commas Between Numbers Free online text tool Commas Between Numbers Commas Between Numbers adds a comma between the numbers in your list. Paste your numbers, choose the options and copy the result. It is free and runs in your browser. Commas Between Numbers Tool Import From File 0Character Count 0Character…

  • Random Color Generator

    Home / Generator Tools / Random Color Generator Free online text tool Random Color Generator Random Color Generator creates a list of random hex colors. Enter how many colors you need, click the button and copy the codes. It is free and runs in your browser. Random Color Generator Number of colors to create: Uppercase…

  • Flip Text

    Flip Text Generator – Reverse Your Text Online | WordTweek Home / Special Effects / Flip Text Free online text tool Flip Text A flip text tool reverses your text so the last character comes first, for example Hello World becomes dlroW olleH. Type or paste your text, then copy the flipped result. It is…

Leave a Reply

Your email address will not be published. Required fields are marked *