Skip to main content

Generate Java classes from schemas

Generate Java classes from Avro, Protobuf, or JSON Schema files to use with Apache Kafka® and Karapace Schema Registry. These classes match your schema structure and help serialize and deserialize messages with the correct data types.

When to generate data classes

Generate data classes if you:

  • Work with schema-based formats such as Avro, Protobuf, or JSON Schema.
  • Want strongly typed Kafka producers and consumers.
  • Use Karapace as your Schema Registry.
  • Prefer Java classes over using generic records or data without a defined schema (such as raw strings or byte arrays).
  • Need to enforce data governance in your Kafka topics.

Prerequisites

Next steps

See schema-specific instructions:

After generating your classes, use them with Kafka and the schema registry to produce and consume messages.