日本語

Filter Network Requests by Condition in Chrome DevTools

​​Chrome DevTools​HTTP,Network

In the Network panel of Chrome DevTools, typing a condition such as status-code:404 or method:POST into the Filter input narrows the list to the requests that match it. This is useful on a page with dozens of requests when you want only the API calls that failed, only the large images, or only the requests to another domain. I built a test page that makes 11 requests, and checked how many requests remained for each condition. The results are below.

Note

The test environment was Ubuntu 24.04 with Chrome for Testing 153.0.8010.12 (the build bundled with Playwright). I started a headed Chrome on a virtual display and operated the DevTools docked below the window by sending mouse and keyboard input. I set DevTools to English, so the button names below are given in English. I did not test macOS or Windows Chrome, the conditions that filter by WebSocket or cookie attributes (such as cookie-domain), or the items in More filters.

The test page and the list before filtering

The page (http://localhost:8080/) loads a CSS file, two images, and a JavaScript file. The JavaScript then makes six requests with fetch. Only the last one goes to a different host (127.0.0.1:8081).

I omitted the definition of the function out, which writes the results to the screen.

js
const call = async (method, url) => { const res = await fetch(url, { method }); out(`${method} ${url} → ${res.status}`); };
(async () => {
  await call('GET', '/api/items');
  await call('POST', '/api/order');
  await call('DELETE', '/api/order/1');
  await call('GET', '/api/missing');
  await call('GET', '/api/broken');
  await call('GET', 'http://127.0.0.1:8081/ads.json');
})();

The server returns the X-Cache: HIT header for /api/items, and Set-Cookie: session=abc123; Path=/ for POST /api/order. /api/missing returns 404, and /api/broken returns 500. The images are cat-small.png at 163 bytes and cat-large.png at 286,443 bytes.

I opened the Network panel and reloaded the page. The list showed the following 11 requests, and the bottom of the panel read "11 requests".

Name Status Size (transferred)
localhost 200 0.5 kB
style.css 200 0.2 kB
cat-small.png 200 0.3 kB
cat-large.png 200 287 kB
app.js 200 0.7 kB
items 200 3.7 kB
order 201 0.2 kB
1 (/api/order/1) 204 0.1 kB
missing 404 0.2 kB
broken 500 0.2 kB
ads.json 200 0.2 kB

When a filter is applied, the bottom text changes to the number of remaining requests out of the total, such as "5 / 11 requests". The results below use these counts.

Plain text matches requests whose URL contains it

If you type plain text without the condition format, the requests whose URL contains that text remain. The official Filter documentation says that plain text is matched against the URL, domain, host name, and port.

Text in the input Bottom text Requests that remained
api 5 / 11 items, order, 1, missing, broken
API 5 / 11 the same 5
127.0.0.1 1 / 11 ads.json

Typing API in uppercase kept the same 5 requests as typing api in lowercase. ads.json does not contain api in its URL (/ads.json), so it did not remain.

Specifying status or method with the "name:value" form

Joining a name and a value with a colon, as in status-code:404, filters by a property of the request. The conditions I tried and their results are below.

Text in the input Bottom text Requests that remained
status-code:404 1 / 11 missing
method:POST 1 / 11 order
domain:127.0.0.1 1 / 11 ads.json
has-response-header:x-cache 1 / 11 items
set-cookie-name:session 1 / 11 order
mime-type:image/png 2 / 11 cat-small.png, cat-large.png
resource-type:fetch 6 / 11 the 6 requests made with fetch
larger-than:100k 1 / 11 cat-large.png
larger-than:1k 2 / 11 cat-large.png, items

The official documentation's list of properties describes all the available names and their meanings. has-response-header keeps requests that have the specified response header. Even when I wrote the header name in lowercase as x-cache, items, which returned X-Cache, remained.

larger-than keeps requests larger than the specified number of bytes. As the official documentation says, 1000 and 1k are treated the same, and both gave 2 results. The 3.7 kB shown in the Size column for items is the transferred size; the JSON body itself is 3,522 bytes. (For how to see the size after decompression in the panel, see the official documentation on Big request rows.) larger-than:3600 kept items, and larger-than:3800 removed it. So larger-than compares the transferred size.

You can use * in domain. domain:*.0.0.1 kept only ads.json, and domain:local* kept the 10 requests other than ads.json.

Choosing values from suggestions is more reliable

When you type a name and the colon, such as method:, a list of value suggestions appears below the input. The suggestions are collected from the requests on the page.

The Filter input with method: typed. Below the input, three suggestions are listed: method:DELETE, method:GET, and method:POST
Typing method: lists the methods that appeared as suggestions

Using a suggestion as-is prevents typos. In my test, values of method were case-sensitive. method:POST kept order, but method:post kept nothing.

Be careful with the faint completion text that appears in the input. When I typed status-code:4, the input showed a faint 04 after status-code:4. It looked like status-code:404, but at that point the list was empty and the bottom read "0 / 11 requests".

The Filter input with status-code:4 typed. A faint 04 appears after it, and the bottom reads 0 / 11 requests
After typing status-code:4, the faint 04 is not yet confirmed

Pressing the Tab key confirmed 404, and the single request missing remained. Adding * as in status-code:4* kept 0 requests. To see everything except 200 at once, use the syntax in the next section.

Excluding matches by putting – in front

Putting - in front of a condition shows the requests that do not match it. Excluding the normal 200 responses leaves only the other statuses in one view.

The Filter input with -status-code:200 entered. The list has four rows: order (201), 1 (204), missing (404), and broken (500). The 404 and 500 rows are in red. The bottom reads 4 / 11 requests
-status-code:200 kept only the requests that were not 200
Text in the input Bottom text Requests that remained
-status-code:200 4 / 11 order (201), 1 (204), missing (404), broken (500)
-domain:localhost 1 / 11 ads.json

Separating with spaces means "all must match"

When you separate conditions with spaces, only the requests that satisfy all of them remain. The official documentation also says that multiple conditions are combined with AND, and that OR is not supported.

Text in the input Bottom text Requests that remained
method:GET status-code:200 mime-type:application/json 2 / 11 items, ads.json
api -status-code:200 4 / 11 order, 1, missing, broken
status-code:404 status-code:500 0 / 11 none

As in the last row, if you try to find either 404 or 500 by writing two conditions side by side, nothing remains, because no request satisfies both at the same time.

To match any of several values, use a regular expression in slashes

Text enclosed in / is treated as a regular expression. With |, you can write an OR condition.

The Filter input with /missing|broken/ entered. The list has two rows, missing (404) and broken (500), and the bottom reads 2 / 11 requests
/missing|broken/ kept the requests whose URL contained either of the two
Text in the input Bottom text Requests that remained
/missing|broken/ 2 / 11 missing, broken
missing|broken (not enclosed in /) 0 / 11 none
/order$/ 1 / 11 order
/^localhost/ 10 / 11 the 10 requests other than ads.json
/^http/ 0 / 11 none
/api\// 5 / 11 items, order, 1, missing, broken
/\/api/ 0 / 11 none

/order$/ means "ends with order", so /api/order remained and /api/order/1 did not.

Be careful when using ^ for the start of the string. In my test, /^localhost/ kept 10 requests, and /^http/ kept none. Matching from the host name, not from the http:// at the start of the URL, worked. In this test, /api\// kept 5 requests, and /\/api/, which puts \/ at the start of the pattern, kept 0.

Combining Invert with the type buttons

Checking Invert to the right of the input inverts the match: requests that matched become hidden, and requests that did not match become visible. With api entered, pressing Invert changed the 5 / 11 display to 6 / 11, and the requests localhost, style.css, cat-small.png, cat-large.png, app.js, and ads.json remained. Pressing it again returned to the original 5.

The buttons below the input, such as All, Fetch/XHR, and Img, filter by request type. The results of my test are below.

Operation Bottom text Requests that remained
Press Fetch/XHR 6 / 11 the 6 requests made with fetch
Then Ctrl+click Img 8 / 11 the 6 above and the 2 images
Then enter larger-than:1k in the input 2 / 11 cat-large.png, items
Clear the input and press All 11 requests all 11 requests

Holding Ctrl and clicking adds types to the selection. On macOS, hold Command and click (see the official documentation on filtering by type). Type buttons and input conditions were combined, and only requests satisfying both remained.

Point

After clearing the input and pressing All, the bottom text returned to "11 requests" without the "/". In this test, while a filter was active, the text showed a "/" in the form "5 / 11 requests".

​Posted by 86