Skip to main content

Filter lines of text

Keep only the lines that contain a piece of text, or exclude them instead, with optional case sensitivity and regular expressions.

  • Clipboard
  • Export
Automate

Embed this widget

Customize the result, check the live preview, then copy the code.

Preview

Embed code type

Code to copy

Responsive and automatically resized by Bethemesh.

Was this tool useful?

On this page

How does this tool work?

Keep only the lines that contain a word, a code or a value, or remove them all at once. The tool works like a “grep” search in your browser: paste an error log, a list of addresses or an export, type the text to find and get the matching lines back in their original order, with the number of kept and excluded lines.

The text is split into lines (Windows, macOS and Linux line endings are recognised) and each line is tested on its own. In “Lines containing the text” mode, a line is kept if it contains the search text anywhere; in the opposite mode, it is kept if it does not. Kept lines are never modified or reordered.

By default the search ignores case: “error” also finds “ERROR” and “Error”, including accented letters (“É” and “é”). Accents, however, count: “resume” does not find “résumé”. Turn on “Match case” to tell capital and small letters apart.

Without the Regular expression option, the text is searched exactly as typed: a dot, a parenthesis or an asterisk are ordinary characters. With the option, the input follows JavaScript regular expression syntax in Unicode mode. Because each line is tested separately, ^ means the start of the line and $ its end. Evaluation runs in a separate process limited to two seconds, so an overly expensive expression cannot freeze the page.

The “Remove blank lines” option, on by default, also drops empty or whitespace-only lines whatever the mode; they are counted as excluded. The text can contain up to one million characters.

How to use this tool

  1. Paste the text

    Type or import a text file, one entry per line.

  2. Set the condition

    Enter the text to find, choose whether to keep or exclude matching lines, then set case sensitivity and regex mode.

  3. Filter and collect

    Run the filter, check the counters, then copy or download the kept lines.

Use cases

Isolate errors in a log

Keep the lines containing ERROR or WARN from a log file to analyse them or attach them to a ticket.

Clean up a list

Exclude addresses from one domain, comment lines starting with # or entries marked “test”.

Extract lines by format

With a regular expression, keep the lines that start with a country code, a date or a specific identifier.

Examples

Keep errors regardless of case

Text “error”, “containing” mode. Both error lines are kept; the two INFO lines and the blank line are excluded (Kept: 2 · Excluded: 3).

Input

2026-10-30 INFO startup
2026-10-30 ERROR disk full

2026-10-31 error network
2026-10-31 INFO shutdown

Result

2026-10-30 ERROR disk full
2026-10-31 error network

Exclude with case matching

Text “ERROR”, “not containing” mode, case matched: only the uppercase line is excluded, along with the blank line.

Input

2026-10-30 INFO startup
2026-10-30 ERROR disk full

2026-10-31 error network
2026-10-31 INFO shutdown

Result

2026-10-30 INFO startup
2026-10-31 error network
2026-10-31 INFO shutdown

Regular expression at the start of the line

Pattern ^FR\d{2} with the Regular expression option: only lines starting with FR followed by two digits are kept.

Input

FR7630006000011234567890189
DE89370400440532013000
note
FR1420041010050500013M02606

Result

FR7630006000011234567890189
FR1420041010050500013M02606

Tips and best practices

  • For an accent-insensitive search, remove the accents from the text first with the dedicated tool, then filter without accents.
  • Combine both modes in two passes: first keep the ERROR lines, then exclude those containing a message you already know.
  • In regular expression mode, escape special characters you want to match literally: \. for a dot, \( for a parenthesis.
  • After filtering, deduplicate or sort the result to get a usable list.

Sources and references

Frequently asked questions

Can I search for several words at once?

Yes, with the Regular expression option and an alternation: ERROR|WARN keeps lines containing either word. Without that option, the vertical bar is searched for literally.

Are kept lines modified?

No. They are copied unchanged, in their original order. Only the excluded lines disappear.

Why does my search not find an accented word?

Case can be ignored, but accents cannot: “resume” does not find “résumé”. Type the word with its accents, or remove accents from both sides first.

What if my regular expression is invalid?

A message says so and nothing is filtered. An expression that would take more than two seconds is stopped without freezing the page.

Is my data sent anywhere?

No. Filtering runs in your browser; the text is not sent to a server.

Related tools

Tools similar or complementary to this one.

Similar tools

Remove duplicate lines from a list while keeping one occurrence of each value.

Text & writingFeaturedUse this tool

Sort the items of a list alphabetically or numerically, in ascending or descending order.

Text & writingUse this tool

Automatically remove empty lines and lines containing only spaces from a text.

Text & writingUse this tool