Skip to main content
ScalaPB

Protocol buffers.
Scala case classes.

ScalaPB turns your .proto files into Scala case classes, with parsers, serializers and lenses ready to use.

person.proto
syntax = "proto3";

message Person {
string name = 1;
int32 id = 2;
optional string email = 3;
}
Person.scala (simplified)
final case class Person(
name: String = "",
id: Int = 0,
email: Option[String] = None,
// ...
) extends scalapb.GeneratedMessage {
// Serialization, lenses and more.
}

Define your messages once. Generate Scala sources as part of your build. Explore the generated API.

Immutable messages.
Familiar Scala.

Create messages with named arguments, update them with lenses, and read or write the standard protobuf binary format.

Generated Scala and Java classes can live side by side, so you can adopt ScalaPB gradually.

Working with messages
Create, update and serialize
val person = Person(name = "Ada", id = 1)

val updated = person.update(
_.email := "ada@example.com"
)

val bytes = updated.toByteArray
val restored = Person.parseFrom(bytes)

Build with ScalaPB

Connect services with gRPC

Generate clients and servers. Use Scala futures or integrations with ZIO, Cats Effect, Akka and Pekko.

Use your own types

Map fields to domain types, choose collections, and share customizations across your proto files.

Share messages across platforms

Reuse your message definitions and Scala code across JVM, Scala.js and Scala Native, with case classes, lenses and binary serialization.