thoughtasylumTOOLBOX Preview Guides Use offline Automate Feedback

Tools › Text

Line Filter

Keep or remove the lines of a log or text file that start with, end with, contain or exactly match some text or a regular expression, or that don't. Rules are checked in order and the first that matches a line decides it. Add context lines and line numbers as grep does, then copy or save the result. It works on plain lines; for a log's levels, times and multi-line entries such as stack traces, use the Log Viewer.

About this tool What it's for, how to use it and an example

What it's for

Pick out the lines of a log or text file you care about, or drop the ones you don’t, by what they start with, end with or contain, or by a regular expression (a pattern for matching text). It does what grep and grep -v do on the command line, with several rules at once. It sees only lines of text: to narrow a log by level or time, with stack traces kept together, use the Log Viewer.

  • When you’re reading a long log and only want the errors, or everything except the debug noise.
  • When you need the lines around each match too, to see what led up to an error.
  • When you’re trimming a list or export to the lines that start or end with something, or that don’t.

How to use it

Paste text, or choose a file or drop one on the page. Add rules, and for each choose Keep or Remove, how it matches, and the text. Ignore case treats capitals and small letters alike. The result updates as you type.

Rules are checked from the top for each line, and the first that matches decides it. Lines no rule matches says what happens to the rest. By default they’re removed when any rule keeps lines, and kept when every rule removes them. Put an exception above the rule it’s an exception to: Remove disk then Keep error gives the errors without the disk ones, but the other way round the keep rule takes every error first. Untick a rule to skip it. Drag the ⠿ handle to change the order, or focus it and press the up and down arrow keys. Each rule shows how many lines it decided.

Context lines adds that many lines before and after each kept line, with -- between groups. Line numbers starts each line with its number in the original, then : for a kept line or - for a context line, as grep does. Copy the result, Save it as a file (named after yours, with -filtered added), or use it as the input to filter again. Your rules and settings are remembered in this browser.

Example

Paste this:

INFO start
DEBUG x=1
ERROR disk full
INFO retry
error: again
DEBUG done

With one rule, Keep lines that contain error with Ignore case ticked, the result is ERROR disk full and error: again, and the tool reports 6 lines in, 2 kept. Set Context lines to 1 and tick Line numbers: the result is now lines 2 to 6, with 3:ERROR disk full and 5:error: again marked as kept.

Good to know

The whole file is read into the page, so very large logs (tens of megabytes) are slow to show. A line is split at each line break, so a message that spans several lines, such as a stack trace, is filtered line by line. Context lines are added around kept lines even if a rule removed them. A rule whose regular expression is broken says why and is skipped.

Guide: Filtering a log or file: Line Filter or Log Viewer?

    Private: this tool runs in your browser. Nothing you type, paste or choose leaves this page.

    Saved you a few minutes? Say thanks with a coffee.

    Something wrong with this tool, or missing from it? Report a bug or suggest a feature.

    ↑ ↓ move↵ openesc close