Keep Line Containing A Certain Word

Free online text tool

Keep Lines Containing A Certain Word

Keep Lines Containing A Certain Word keeps only the lines that contain the word or text you type. Paste your text, enter the word and copy the result. It is free and runs in your browser.

Keep Lines Containing a Certain String/Word

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

Keep Lines Example

Before (keep lines containing sun)
He ate his first marshmallow.
The sun was very bright.
He ran very quickly to the store.
After
The sun was very bright.

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 Word do?

This tool keeps the lines that contain the word or text you type and removes all other lines. A line stays if the text appears anywhere in it.

The match works on any text, not only whole words, so sun also keeps a line with sunny or sunset. By default capital letters do not matter. Tick 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.

Keep lines containing a certain word examples

Each example shows the word used. Capitals are ignored unless Match case is on.

SettingBeforeAfter
Word: sun
He ate his first marshmallow.
The sun was very bright.
He ran very quickly to the store.
The sun was very bright.
Word: error
ok: saved
error: disk full
ok: sent
error: timeout
error: disk full
error: timeout
Not a whole word (sun)
sunny day
sunset
moon
sunny day
sunset
Match case off (default, cat)
Cat food
cat toy
dog bowl
Cat food
cat toy
Match case on (cat)
Cat food
cat toy
dog bowl
cat toy
Empty lines removed (a)
a1

b2
a3
a1
a3

How to keep lines containing a certain word

  1. 1
    Add your text
    Type or paste your lines into the box, or import a text file.
  2. 2
    Enter the word
    Type the word or text that the lines you want to keep contain. Tick Match case if capitals matter.
  3. 3
    Click Keep Lines
    Only the lines that contain your text 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 a word

Good for

Finding the lines you need in a log, a list of names or an export, and removing everything else in one step.

Check first

The text matches inside words too, and spaces count, so cat also keeps a line with 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 delete the matching lines instead, try Remove Lines Containing A Certain Word. To get rid of blank lines, try Remove Empty Lines.

Keep lines containing a certain word FAQ

What does the Keep Lines Containing A Certain Word tool do?

It keeps only the lines that contain the word or text you enter and removes all other lines.

How do I keep lines containing a certain word?

Type or paste your text, enter the word in the Keep lines that contain box and click Keep Lines. The result replaces the text in the box. Click Copy to use it, or Undo to go back.

Does it match whole words only?

No. It matches the text anywhere in a line, so sun also keeps a line with sunny or sunset.

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.

Can I search for more than one word?

You can search for a phrase, such as red car, and a line is kept if it contains that exact text. It does not search for several different words at once.

What happens to empty lines?

They are removed, because an empty line does not contain your text.

What if no line contains my word?

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

  • Url Slug Generator

    URL Slug Generator – Create SEO-Friendly Slugs Online | WordTweek Home / Generators / URL Slug Generator Free online text tool URL Slug Generator This tool creates SEO-friendly URL slugs from any text. Enter your title and the slug appears instantly, in lowercase with clean separators and no special characters. It is free and runs…

  • 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…

  • Reverse Words

    Reverse Words Tool – Reverse Word Order in a Sentence Online | WordTweek Home / Special Effects / Reverse Words Free online text tool Reverse Words This reverse words tool quickly reverses the order of words in a sentence, so the last word comes first, for example Hello World becomes World Hello. Words keep their…

  • Binary Code To Text

    Home / Special Effects Tools / Binary Code To Text Free online text tool Binary Code To Text Binary Code To Text converts binary numbers, written with 0s and 1s, into readable text. Paste your binary code, click the button and copy the text or sentence. It is free and runs in your browser. Binary…

Leave a Reply

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