Skip to content
jshacks.dev
Debugging

Inspect WebSocket frames in the Network panel

Read the messages sent and received on a WebSocket in Chrome DevTools by filtering the Network panel to WS and opening the Messages tab.

1 min read
Summarize in AI

A WebSocket has no request and response, only a stream of frames, so the console shows nothing by itself. The Network panel records every frame.

socket.jsJavaScript
const ws = new WebSocket("wss://echo.example.test");
ws.addEventListener("open", () => ws.send(JSON.stringify({ type: "ping" })));
ws.addEventListener("message", (e) => console.log(e.data));

Open Network, click the WS filter, reload so the connection is recorded, and select the socket. The Messages tab lists the frames: an up arrow in green for sent data and a down arrow in red for received data, each with its length and time. For this echo server:

Text
↑ {"type":"ping"}
↓ {"type":"ping"}

Click a frame to read its full text. The tab also filters frames by text and, for binary frames, shows them as opcode and length. See Inspect WebSocket messages.

The panel must be open before the socket connects, or you will not see the earlier frames, which is why the reload matters. The Messages tab does not edit or resend frames, so use a client tool for that.

Frames may hold tokens or personal data, so be careful with screenshots.

Also inAPIs
Share

More snippets

Debugging

Group related logs with console.group

Indent related console output under a label with console.group and console.groupEnd, so interleaved logs from one request stay readable in Node.js 24.

1 min read
APIs

Fetch JSON and handle HTTP errors

Fetch JSON in the browser or Node.js 24 and throw on 404 or 500 yourself, because fetch only rejects on network failure and does not check the status.

1 min read
Debugging

Inspect an object with console.dir

Show nested objects beyond the default depth of two with console.dir and the depth option, instead of the [Object] placeholders console.log prints.

1 min read

Get new posts by email

We send one email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.