What is a schema registry? A guide for Kafka

What is a schema registry? A guide for Kafka

Learn the fundamentals of schema registry for Kafka and how Redpanda schema registry makes it all much simpler

March 30, 2023
Last modified on
December 2, 2026

What Is a Schema Registry?

A schema registry is a central service that stores, versions, and validates the schemas producers and consumers use to serialize and deserialize messages. Instead of every application defining message formats on its own, a producer registers a schema once, the registry assigns it a unique ID, and each message carries that small ID instead of the full schema. Consumers use the ID to fetch the exact schema they need to read the data. The registry also checks every new schema version against compatibility rules, so a change in one service doesn’t break another.

A schema, in simple terms, is a description of how data is structured: the fields a message contains, their data types, and which ones are required. In streaming, schemas are usually written in Apache Avro™, Protocol Buffers (Protobuf), or JSON Schema.

Apache Kafka® doesn’t include a schema registry. It stores and delivers messages as raw bytes and leaves their structure to applications, so most Kafka users run a separate registry service alongside their cluster. Redpanda takes a different approach and builds its schema registry directly into every broker. This article explains how a schema registry works, what it adds to every message, how schema evolution works, and when you need one.

What does it mean to serialize and deserialize a message in Kafka?

In the Kafka client API model, a message (a record) is the smallest data exchange unit. A message contains a key and a value, carrying arbitrary information related to business use cases.

A serializer converts a business object in memory into a byte array to save or transmit it easier, so a Kafka producer client invokes a serializer before a message is written to the network. On the other hand, a deserializer reverses the process by constructing a business object from a byte array, and so a Kafka consumer client invokes a deserializer right after it reads a message from the network.

Since a schema defines the structure of the data format, serializers and deserializers use the schema to influence the shape of data during the serialization/deserialization process. In the context of Kafka APIs, serializers and deserializers are a part of the language-specific SDK, and support data formats including Apache Avro™, JSON Schema, and Google’s Protobuf. (For Kafka, Avro is by far the most popular choice for data serialization.)

The following figure sums it all up:

Diagram of how serializers and deserializers work to process a schema format
Diagram of how serializers and deserializers work to process a schema format

Why do you need schema registry?

When there's a message, the serializer does its job based on the schema specified. This schema is often called the writer's schema. When the message gets deserialized, the deserializer always needs a schema to continue, and it’s called the reader's schema.

The question is how the deserializer gets the writer’s schema. Without a registry, you have two options:

  • Send the full schema with every message. The consumer always has the schema it needs, but schemas are often larger than the data they describe, so message size and network traffic grow for no benefit.
  • Share the schema out of band. Teams pass schema files around or hard-code them in producer and consumer code. That works for one producer and one consumer, but it breaks down as more teams read the topic and the schema changes.

Neither option protects you from the bigger risk: a producer changing the format in a way existing consumers can’t read. The broker can’t catch the problem, because it treats every message as bytes. The first sign of trouble is usually a consumer failing in production.

A schema registry solves both problems. It keeps every schema in one place, lets each message carry a compact ID instead of the full schema, and rejects incompatible schema changes before any producer can use them.

How does schema registry work in Kafka?

Diagram showing how a schema registry serves as a central location for schemas
Diagram showing how a schema registry serves as a central location for schemas

Kafka only transfers data in byte format. In fact, it doesn’t know what kind of data it’s sending or receiving. But producers and consumers need to know what type of data they’re handling so they can process it correctly. When a producer sends a message to a Kafka cluster, the data can be in any format the producer chooses. So every time you change the schema for messages, every related consumer and producer needs to know.

A schema registry makes this easy by providing a central repository that consumers and producers can access to find out the schema of a given message. The schema registry also maintains a history of schemas and supports a schema evolution strategy, so you can plan how future applications will maintain compatibility with a certain schema—even if you add or remove fields later.

Understanding the schema registry information hierarchy

A schema registry organizes information in three levels:

  • Subject: A named scope that groups the versions of one schema. By default, serializers use the topic name strategy, so a topic called orders gets two subjects: orders-value for message values and orders-key for message keys. Other strategies, such as the record name strategy, name subjects after the record type instead, which lets one topic carry several event types.
  • Version: Each change registered under a subject gets the next version number, starting at 1. Versions are scoped to their subject, so orders-value and payments-value each have their own version 1.
  • Schema ID: A unique number the registry assigns to each distinct schema, across all subjects. This is the ID serializers put in messages. If you register a schema that already exists, even under a different subject, the registry returns the existing ID instead of creating a new one.

For example, the first schema you register under orders-value becomes version 1 and might receive ID 1. If other teams then register schemas for their own topics, your next orders-value change becomes version 2 but could receive ID 15. Consumers never need to track versions; the ID in each message is enough to fetch the exact schema that wrote it.

How does serialization work with schema registry in Kafka?

The schema registry wire format

Serializers that use a schema registry don’t change the Kafka message format itself. Instead, they prefix the serialized key or value with a small header. In the widely used Confluent-compatible wire format, which Redpanda also uses, every serialized message starts like this:

  • Byte 0: magic byte. Always 0. It tells the deserializer that the message uses the schema registry wire format.
  • Bytes 1–4: schema ID. A 4-byte, big-endian integer that identifies the schema in the registry.
  • Bytes 5 and onward: payload. The data serialized with that schema, as Avro binary, Protobuf, or JSON.

For Protobuf, one extra field sits between the schema ID and the payload: a short list of message indexes that identifies which message type in the .proto file was used, because one Protobuf schema can define several message types.

That 5-byte prefix is all a consumer needs. A deserializer that finds a first byte other than 0 knows the message wasn’t written by a registry-aware serializer and rejects it.

‍

Illustration of how a message is constructed within a schema
Illustration of how a message is constructed within a schema

Finally, the serializer serializes the message and returns the byte sequence to the producer.

How does deserialization work with schema registry in Kafka?

Basically, the consumer fetches messages from Redpanda and hands them over to the deserializer. The deserializer first checks the existence of the magic byte and rejects the message if it doesn't.

The deserializer then reads the schemaID and checks whether the related schema exists in its local cache. If that exists, deserialization happens with that schema. Otherwise, the deserializer retrieves the schema from the registry based on the schemaID. Once the schema is in place, the deserializer proceeds with the deserialization.

Is a Schema Registry Required for Kafka?

No. Kafka works without one, and so does Redpanda. Producers can send plain JSON or strings, and consumers can parse them however they like. A schema registry becomes worth it once the cost of a broken message outweighs the cost of managing schemas:

  • You use Avro or Protobuf. These binary formats can’t be read without the schema, so you need a reliable way to share it.
  • Several teams or services consume the same topics. A registry replaces informal agreements with an enforced contract.
  • Your schemas change often. Compatibility checks catch breaking changes before they reach consumers.
  • You need governance or auditability. The registry keeps a versioned history of every message format.

You can usually skip it for prototypes, single-team pipelines where one codebase owns both the producer and the consumer, or topics that carry unstructured data such as logs.

How Redpanda makes schema registry in Kafka simpler

Redpanda is a Kafka API-compatible streaming data platform that eliminates Zookeeper® and the JVM, autotunes itself for modern hardware, and ships in a single binary to give you 10x lower latencies and cut your cloud spend—without sacrificing your data’s reliability or durability.

Redpanda builds the schema registry directly into every broker. There’s no separate service to deploy, scale, or secure. The registry stores schemas in Redpanda’s own replicated storage, listens on port 8081 by default, and implements the Confluent Schema Registry API, so existing serializers, deserializers, and tools work without code changes. It supports Avro, Protobuf, and JSON Schema, along with the full set of compatibility modes.

Because the registry lives inside the broker, Redpanda can also validate schema IDs on the server. With server-side schema ID validation enabled for a topic, the broker checks each record’s schema ID against the registry and drops records with unregistered schemas, so bad data is caught when it’s produced rather than when a consumer fails to read it.

You can manage schemas with the Schema Registry API, with rpk registry commands, or visually in Redpanda Console.

The diagram below shows how it all works together.

 Interaction flow among producers, consumers, and Redpanda schema registry
Interaction flow among producers, consumers, and Redpanda schema registry

Start using Redpanda schema registry

Once Redpanda is running, the schema registry is already available on port 8081. You can register and inspect schemas with rpk:

rpk registry schema create orders-value --schema order.avsc
rpk registry subject list
rpk registry schema get --id 1
rpk registry schema check-compatibility orders-value --schema order-v2.avsc

The last command checks whether a proposed new version is compatible with the subject’s existing versions before you register it. For the full set of endpoints, see the Schema Registry API reference.

What’s next

In this first post, you learned the importance of having a schema registry in a streaming data architecture and some inner workings of message serialization and deserialization within the scope of a Kafka client application. Moreover, we explored the basics of the Redpanda schema registry and how it supports modern architectures like serverless Kafka.

In our next post, we’ll walk you through how you can use Redpanda’s built-in schema registry to produce and consume Avro messages—in just five steps. Make sure to subscribe to our blog so you don’t miss a post!

To learn more about Redpanda, check out our documentation and browse the Redpanda blog for tutorials and guides on how to easily integrate with Redpanda. For a more hands-on approach, take Redpanda's free Community edition for a spin.

If you get stuck, have a question, or just want to chat with our engineers and fellow Redpanda users, join our Redpanda Community on Slack.

FAQ

Is Redpanda compatible with the Confluent Schema Registry API?

Yes. Redpanda’s built-in schema registry implements the Confluent Schema Registry API and uses the same wire format, so Confluent serializers, deserializers, and other tools built on the API work with Redpanda without code changes. Point your client’s schema.registry.url setting at a Redpanda broker on port 8081.

Why use Avro instead of JSON?

Plain JSON repeats every field name in every message and has no built-in types or contract, so messages are larger and nothing stops a producer from changing their shape. Avro serializes data into a compact binary form without field names, validates it against a schema, and has well-defined rules for schema evolution. The trade-off is that Avro messages aren’t human-readable without the schema. If you want to stay with JSON, JSON Schema adds validation and compatibility checks through the same registry.

What is the purpose of a schema?

A schema defines the structure of data, such as its fields, types, and required values, so every system that writes or reads the data agrees on what it means. In streaming, schemas let producers serialize data consistently, let consumers deserialize it correctly, and give teams a contract they can evolve safely over time.

No items found.

Related articles

View all posts
Daniel Takabayashi
,
,
&
Oct 22, 2026

Build an AI agent once and reuse it across teams

How Redpanda Agentic Data Plane keeps IT, HR, and ops agents unified and controlled across reuses

Read more
Text Link
Trevor Blackford
,
Matt Schumpert
,
&
Aug 25, 2026

Push-button migration from Confluent to Redpanda

Redpanda Shadowing now carries topic data, schemas, offsets, and ACLs on a single link for a low-risk, no-data-loss cutover

Read more
Text Link
Alexander Gallego
,
,
&
Aug 3, 2026

Agentic kill switch is a database problem. So we built Redpanda SQL

A database designed for agentic governance, now available on Google Cloud

Read more
Text Link
PANDA MAIL

Stay in the loop

Subscribe to our VIP (very important panda) mailing list to pounce on the latest blogs, surprise announcements, and community events!
Opt out anytime.