explaingit

edenhill/kcat

5,755CAudience · ops devopsComplexity · 2/5Setup · easy

TLDR

kcat is a lightweight command-line tool for sending and reading messages on Apache Kafka from your terminal without needing Java, a single small binary handles producing, consuming, and inspecting a Kafka cluster.

Mindmap

mindmap
  root((kcat))
    Modes
      Producer mode
      Consumer mode
      Metadata mode
    Features
      Avro decoding
      SSL and SASL auth
      Consumer groups
      Offset control
    Tech
      Written in C
      No Java needed
      Under 150KB binary
    Install
      apt on Debian
      Homebrew macOS
      Docker image
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Pipe a file of JSON records into a Kafka topic with one command to quickly load test data into a pipeline.

USE CASE 2

Read messages from a Kafka topic and pipe them into jq or grep to debug a production event stream without writing code.

USE CASE 3

Print a full map of all brokers, topics, and partition offsets in a Kafka cluster to inspect cluster health.

USE CASE 4

Test SSL and SASL authentication settings against a secured Kafka cluster from the terminal before wiring up an application.

Tech stack

ClibrdkafkaDocker

Getting it running

Difficulty · easy Time to first run · 5min

In plain English

kcat (previously named kafkacat) is a command-line tool for working with Apache Kafka, the distributed messaging system used to pass data between applications. The tool is written in C and does not require the Java runtime that most official Kafka tooling depends on, which makes it much smaller and faster to start up. The statically linked binary is under 150 kilobytes. Apache Kafka organizes data into named topics, and each topic is split into partitions. Messages flow from producers (things that write data) to consumers (things that read data). kcat lets you do both directly from the terminal, making it useful for debugging, testing pipelines, or piping data in and out of Kafka without writing any code. In producer mode, kcat reads lines from standard input and sends each one as a message to a topic you specify. You can also read from files, set compression, add headers, produce transactions, and enable exactly-once delivery guarantees. In consumer mode, kcat reads messages from a topic and prints them to standard output. You can subscribe to multiple topics at once, join a consumer group for balanced reading across instances, seek to specific offsets or timestamps, and control the output format. There is also a metadata mode that prints a summary of the entire Kafka cluster, including all brokers, topics, and partitions. The tool supports Avro message decoding through the Confluent Schema Registry, and it can deserialize keys or values using custom primitive format strings. Any Kafka configuration setting can be passed on the command line or stored in a config file, including SSL and SASL authentication settings for secure clusters. kcat is available via apt on Debian systems, Homebrew on macOS, dnf on Fedora, and as a Docker image. It can also be built from source using a bootstrap script that downloads and compiles its dependencies automatically.

Copy-paste prompts

Prompt 1
Use kcat to consume the last 100 messages from a Kafka topic called orders on localhost:9092 and pretty-print them as JSON using jq.
Prompt 2
Write a kcat command to produce every line from orders.json as a separate message to the orders topic on localhost:9092 with gzip compression enabled.
Prompt 3
How do I use kcat in metadata mode to list all topics in my Kafka cluster along with their partition counts and leader broker IDs?
Prompt 4
Set up kcat with SASL PLAIN authentication and TLS to connect to a secured Confluent Cloud Kafka cluster and read from a topic.
Prompt 5
How do I use kcat to seek to a specific timestamp offset and read messages from that point forward in a Kafka topic?
Open on GitHub → Explain another repo

← edenhill on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.