WS · RFC 6455 Frame Utility

WebSocket Frame Decoder

Decode raw WebSocket frame bytes and inspect FIN, RSV flags, opcode, masking, payload length, masking key, unmasked payload and readable text.

✓ FIN / RSV✓ Opcode✓ Masking ✓ 7 / 16 / 64-bit Length✓ Text Payload✓ Control Frames
WS
WebSocket Frame Decode
● Ready
Paste one complete WebSocket frame beginning with the first frame-header byte. Spaces, commas, colons, hyphens, continuous hex and 0x-prefixed bytes are accepted.
Strict mode reports bytes that remain after the declared payload.
Decoder scope: input starts at the WebSocket frame header. HTTP Upgrade request/response headers, TCP/IP headers and TLS records are not part of a WebSocket frame. Client-to-server frames normally use masking; server-to-client frames normally do not.
WebSocket Frame Decode Result Frame Decoded
Decoded Frame
FIN
Opcode
Frame Type
Masked
Payload Length
Header Length
Masking Key
Total Frame Size
Payload
Frame Header Breakdown
Validation

What Is a WebSocket Frame?

After a WebSocket connection is established, application data is transferred as WebSocket frames. Each frame begins with a compact header containing the FIN flag, three reserved bits, a four-bit opcode, a MASK flag and payload-length information.

The header may also contain an extended payload length and a four-byte masking key. The actual application payload follows the header.

WebSocket Frame Header Format

FieldSizePurpose
FIN1 bitMarks the final fragment of a message
RSV1–RSV33 bitsReserved for negotiated extensions
Opcode4 bitsIdentifies continuation, text, binary or control frame
MASK1 bitIndicates a four-byte masking key
Payload Length7 bitsLength value or marker for extended length
Extended Length0, 2 or 8 bytesUsed for larger payloads
Masking Key0 or 4 bytesUsed to XOR/unmask the payload
PayloadVariableApplication or control-frame data

WebSocket Text Frame Example

81 05 48 65 6C 6C 6F 81: FIN = 1 Opcode = 0x1 (Text) 05: MASK = 0 Payload length = 5 48 65 6C 6C 6F: "Hello"

WebSocket Masking

Masked frames contain a four-byte masking key immediately before the payload. Each payload byte is XORed with one byte of that key, repeating the key every four bytes.

decoded[i] = encoded[i] XOR mask[i mod 4]

WebSocket clients use masking for frames sent to servers. Frames sent from a server to a client are normally unmasked.

WebSocket Payload Length

Payload lengths from 0 through 125 are stored directly in the second header byte. A value of 126 means that the following two bytes contain a 16-bit unsigned payload length. A value of 127 means that the following eight bytes contain a 64-bit unsigned payload length in network byte order.

WebSocket Opcodes

OpcodeMeaningCategory
0x0ContinuationData
0x1TextData
0x2BinaryData
0x8CloseControl
0x9PingControl
0xAPongControl

WebSocket Frame Decoder FAQs

What does 0x81 mean in a WebSocket frame?
0x81 normally represents FIN=1 with opcode 0x1, meaning a final text frame when no RSV bits are set.
What does the MASK bit mean?
MASK indicates whether a four-byte masking key is present and whether the payload bytes must be unmasked using XOR.
Why are WebSocket client frames masked?
The WebSocket framing protocol requires frames sent from clients to servers to be masked.
Can WebSocket messages contain multiple frames?
Yes. A message can be fragmented into an initial text or binary frame followed by continuation frames until a frame with FIN=1 completes the message.
Does this tool decode HTTP WebSocket handshakes?
No. It begins at the binary WebSocket frame header after the HTTP Upgrade handshake has established the WebSocket connection.
What are WebSocket control frames?
Close, Ping and Pong are control frames. Their payloads are limited to 125 bytes and control frames cannot be fragmented.
Scroll to Top