Skip to content
uencoder
TASK

Understand WebSocket frame format

WebSocket frames have a specific binary format with opcode, masking, and payload length. Learn to decode and construct WebSocket frames.

  1. 1

    A WebSocket frame starts with 2 bytes: FIN + RSV + opcode (1 byte), MASK + payload length (1 byte). Opcodes: 0x0 (continuation), 0x1 (text), 0x2 (binary), 0x8 (close), 0x9 (ping), 0xA (pong). Client-to-server frames must be masked (4-byte mask key + XOR'd payload). Payload length: 0-125 inline, 126 = 16-bit length follows, 127 = 64-bit length follows.

  2. 2
    Hex Encoder →

    Encode a WebSocket frame. For a text frame "Hello": FIN=1, opcode=1 → 0x81. MASK=1, length=5 → 0x85. Mask key (4 random bytes). Payload: each byte XOR'd with mask key cyclically. The server unmask by XOR'ing again.

  3. 3
    Base64 Encoder →

    Encode binary WebSocket payloads as base64 for debugging. Binary frames (opcode 0x2) can contain any data — base64 makes it inspectable in text tools and logs.

Frequently asked questions

Why must client frames be masked?
Masking prevents cache poisoning attacks on intermediaries (proxies, caches) that might misinterpret WebSocket data as HTTP responses. The mask is a 4-byte key applied with XOR — the server unmasks to recover the original payload. Server-to-client frames are not masked.
What are ping/pong frames for?
They are heartbeat frames. The client or server sends a ping (opcode 0x9), and the other side must respond with a pong (opcode 0xA) with the same payload. This keeps the connection alive through idle timeouts and checks if the peer is responsive. Send pings every 30-60 seconds.

Workflows that solve this

Convert Ascii85 to Base64
Decode Ascii85 and re-encode as Base64 for wider compatibility.
PIPELINE
Convert Base2048 to Base64
Decode Base2048 (emoji) and re-encode as Base64 for standard transport.
PIPELINE
Convert Base32 to Base64
Decode a Base32-encoded string into raw bytes and re-encode as Base64 for more compact representation.
PIPELINE
Convert Base32 to Hex
Decode Base32 and re-encode as hex for debugging.
PIPELINE
Convert Base58 to Base64
Decode Base58 and re-encode as Base64 for standard compatibility.
PIPELINE
Base64 encode then decode round-trip
Encode text to Base64 and decode it back to verify the round-trip preserves the original data.
PIPELINE
Convert Base64 to Hex
Decode a Base64 string into raw bytes and re-encode it as hexadecimal for inspection or interop.
PIPELINE
Convert Binary to Hex
Decode a binary (base-2) string into its byte value and re-encode as hexadecimal.
PIPELINE
Blowfish Encrypt then Base64
Blowfish encrypt then Base64-encode for text-safe transport.
PIPELINE
ChaCha20 Encrypt then Hex
ChaCha20 encrypt then hex-encode the ciphertext.
PIPELINE
DES Encrypt then Base64
DES encrypt then Base64-encode for legacy compatibility.
PIPELINE
Encode a JSON payload for URL transport
Prepare a JSON document for a URL parameter: pretty-print, Base64-encode, then percent-encode — the exact inverse of the nested-parameter decode chain.
PIPELINE
AES encrypt then Base64 encode
Encrypt plaintext with AES and encode the ciphertext as Base64 for text-safe transport.
PIPELINE
Hash content and encode as Base64
Compute a hash of the input and encode the hash digest as Base64 for compact transport.
PIPELINE
Hex encode then decode round-trip
Encode text to hexadecimal and decode it back to verify the round-trip preserves the original data.
PIPELINE
Hex-encode text and analyze
Convert text to its hexadecimal representation then compute character statistics on the hex output.
PIPELINE
Convert Hex to Base64
Decode a hexadecimal string into raw bytes and re-encode it as Base64 for compact transport.
PIPELINE
HMAC Sign then Base64 Encode
Generate HMAC signature then Base64-encode for API auth headers.
PIPELINE
Morse Encode and Base64 Transport
Encode text as Morse code then Base64-encode for digital transport.
PIPELINE
Convert Multibase to Hex
Decode multibase and re-encode as plain hex.
PIPELINE
Convert Octal to Hex
Decode octal and re-encode as hex for compact representation.
PIPELINE
RC4 Encrypt then Base64
RC4 encrypt then Base64-encode for transport.
PIPELINE
Reverse text and show hex encoding
Reverse a string then inspect its hexadecimal representation — useful for debugging byte-order issues and encoding puzzles.
PIPELINE
RIPEMD-160 Hash then Base64
Compute RIPEMD-160 hash then Base64-encode for transport.
PIPELINE
SHA-512 Hash then Hex Encode
Compute SHA-512 hash then encode as hex for readability.
PIPELINE
Shuffle Text and Base64 Encode
Shuffle text characters then Base64-encode the result.
PIPELINE
Unicode Escape and Base64 Encode
Unicode-escape text then Base64-encode for ASCII-safe transport.
PIPELINE
Decode URL and show hex bytes
Percent-decode a URL-encoded string then view its hexadecimal byte representation for low-level analysis.
PIPELINE
URL Encode then Base64 Double Encode
URL-encode then Base64-encode for double encoding in API payloads.
PIPELINE
Encode a text payload for URL transport
Percent-encode text then show its hex representation for safe URL parameter transport.
PIPELINE
UUencode then Base64
UUencode text then Base64-encode the result for double encoding.
PIPELINE
Generate UUID and Base64 Encode
Generate a UUID then Base64-encode it for compact storage.
PIPELINE
XXencode then Hex
XXencode text then hex-encode the result.
PIPELINE

Learn more

Want to understand why?

Related tools