Keep or Remove Lines

Use this tool to filter a list or block of text line by line. Paste your text (one item per line), enter a keyword or pattern, then choose whether to keep only matching lines or remove them. This is useful for cleaning lists, extracting specific items, filtering logs, and removing unwanted entries from copied data.

Matching can be case-insensitive (default) or case-sensitive. You can also switch match types depending on what you need: contains (default), exact match, starts with, ends with, or regex. For messy input, enable trim and ignore empty lines to avoid confusing “nothing matches” situations.

Filter Lines by Pattern

Keep or remove lines using keyword, exact match, starts/ends-with, or regex.

How to keep or remove matching lines

  1. Paste your text (one item per line).
  2. Enter the pattern to match.
  3. Choose Keep matching lines or Remove matching lines.
  4. Pick match type and options.
  5. Click Apply Filter, then copy or download the output.

Examples

Remove lines containing “debug”

debug: start info: boot debug: step 1 error: failed

info: boot error: failed

Keep only lines containing “error”

info: boot warn: retry error: failed info: done

error: failed

Keep domains ending in “.com” (ends-with)

example.com example.net site.com

example.com site.com

Match options

  • Match type: contains, exact, starts with, ends with, regex
  • Case-sensitive: match exact casing when needed
  • Invert match: flip what counts as a match
  • Trim whitespace: avoid false negatives due to leading/trailing spaces
  • Ignore empty lines: drop blank lines before filtering

Troubleshooting

  • Nothing matches: check for leading/trailing spaces and try Trim.
  • Too many matches: use Exact match or Regex with word boundaries (e.g., \\berror\\b).
  • Case mismatch: enable Case-sensitive only when needed.
  • Regex errors: if the regex is invalid, switch to Contains or fix the pattern.

Common questions

Does this tool support regex?

Yes. Choose Match type → Regex. If your regex is invalid, the tool will show an error.

What does “case-insensitive” mean?

Case-insensitive matching treats ERROR, Error, and error as the same. Turn on Case-sensitive if you need exact casing.

How do I keep only lines that start with a prefix?

Select Match type → Starts with, then enter the prefix text. Choose Keep matching to keep only those lines.

How do I keep only lines that end with a suffix like .log or .com?

Select Match type → Ends with and enter .log or .com. Choose Keep matching.

Can I invert the match to keep non-matching lines?

Yes. Turn on Invert match, then choose Keep matching.

Can I filter logs quickly with this?

Yes. Paste log lines, then Keep matching for a keyword (like error) or Remove matching for noise (like debug).

Can I upload a file and export results?

Yes. Use Upload File to load text, and Download to export the filtered result as a .txt file.

Will my text be uploaded to a server?

No. The filtering runs in your browser; your text stays on your device.

How do I match whole words only?

Use Regex match type and a word-boundary pattern like \berror\b (depending on your exact needs).

How do I remove empty lines too?

Enable Ignore empty lines so blank lines are excluded before filtering.

Related tools