What Is the Kafka Wire Protocol?
Apache Kafka uses a size-delimited binary request/response protocol over TCP. Every request identifies an API and API version, includes a correlation ID, and may include a client ID. The parser above maps those values back to their exact byte ranges without connecting to a Kafka broker.
Kafka Frame and Header Format
| Field | Encoding | Purpose |
|---|---|---|
| Frame length | INT32 | Bytes following the four-byte length prefix |
| API key / version | INT16 + INT16 | Selects the request body schema |
| Correlation ID | INT32 | Matches a response to its request |
| Client ID | NULLABLE_STRING | Identifies the client application |
Why Kafka Responses Need Request Context
A Kafka response contains its correlation ID but does not repeat the request API key and version. Choose the matching API and version above when decoding an isolated response. The tool never guesses this context; missing context is reported as a diagnostic.
Supported Kafka APIs and Versions
ByteLens decodes framing and request headers for every API. It deeply decodes ApiVersions requests and responses for versions 0–4, Metadata requests for versions 0–12, and Metadata responses for versions 0 and 9. Other bodies remain visible as raw bytes with an explicit unsupported status. Flexible versions use compact fields, unsigned varints, and tagged fields.
Related Protocols
Kafka messages are carried over persistent TCP connections. Inspect the transport header in the TCP packet parser, or compare other application payload formats in the Redis wire protocol parser. Browse every supported decoder in the protocol parser directory.
Kafka Protocol Parser FAQ
Does this tool connect to my Kafka cluster?
No. Parsing happens locally from the bytes you paste and no broker credentials are required.
Can it decode every Kafka API body?
No. The support matrix above is deliberately explicit; unsupported bodies are not guessed.
Specification source: Apache Kafka Protocol Guide 4.1.