Scala Shell
Clone or download
Latest commit 8c00578 Jul 15, 2018
Failed to load latest commit information.
.github Add May 30, 2016
.travis Start publishing api docs using travis May 28, 2018
compiler-plugin Remove test for packageless protos Jul 8, 2018
e2e Fix compilation of package-less protos with single_file=true Jul 8, 2018
examples/custom_options Update to SBT 1.1.5 May 21, 2018
lenses/shared/src Add scalafmt Jun 6, 2018
project Fix release process Jul 9, 2018
proptest/src/test/scala Add scalafmt Jun 6, 2018
protobuf/scalapb Add file-level option to customize the generated proto object name May 31, 2018
scalapb-runtime-grpc/src Add scalafmt Jun 6, 2018
scalapb-runtime move FieldMaskUtilPropSpec. fix compile error in js and native test Jul 6, 2018
scalapbc update protobuf version to 3.6 Jul 16, 2018
third_party/google/protobuf Update third_party protobuf from protobuf-3.3.1 Jul 15, 2017
.gitignore Merge scalapb/Lenses.git into scalapb/ScalaPB May 29, 2018
.scalafmt.conf Add scalafmt Jun 6, 2018
.travis.yml Make tests use commons-codec for Base64 instead of javax.xml.bind.Dat… Jun 26, 2018 Implement sealed oneofs Jul 5, 2018
LICENSE Initial commit Oct 13, 2014 Merge scalapb/Lenses.git into scalapb/ScalaPB May 29, 2018
build.sbt update protobuf version to 3.6 Jul 16, 2018 Implement sealed oneofs Jul 5, 2018 Add Scala native support Jan 14, 2018 Implement sealed oneofs Jul 5, 2018 Travis: break e2e and proptest into separate virtual machines for eac… Jun 11, 2017
sonatype.sbt Fix release process Jul 9, 2018 update dependencies Mar 24, 2018
version.sbt Setting version to 0.8.0-SNAPSHOT Jul 9, 2018


Join the chat at

Build Status

ScalaPB is a protocol buffer compiler (protoc) plugin for Scala. It will generate Scala case classes, parsers and serializers for your protocol buffers.

ScalaPB generates case classes that can co-exist in the same project alongside the Java-generated code for ProtocolBuffer. This makes it easy to gradually migrate an existing project from the Java version of protocol buffers to Scala. This is achieved by having the ScalaPB generated code use the proto file as part of the package name (in contrast to Java which uses the file name in CamelCase as an outer class)

Each top-level message and enum is written to a separate Scala file. This results in a significant improvement in incremental compilations.

Another cool feature of ScalaPB is that it can optionally generate methods that convert a Java protocol buffer to a Scala protocol buffer and vice versa. This is useful if you are gradually migrating a large code base from Java protocol buffers to Scala. The optional Java conversion is required if you want to use fromAscii (parsing ASCII representation of a protocol buffer). The current implementation delegates to the Java version.


  • Supports proto2 and proto3

  • Easily update nested structure in functional way using lenses

  • Scala.js integration

  • GRPC integration

  • Compatible with SparkSQL (through a helper library)

  • Conversion to and from JSON

  • Support user-defined options (since 0.5.29)

  • Support extensions (since 0.6.0)


Version Description
0.6.x Stable. Supports Protobuf 2.6.x to 3.5.x
0.5.x Supports Protobuf 2.6.x and Protobuf 3.1.x.
0.4.x Stable, unsupported. Works with Protobuf 2.6.x


To automatically generate Scala case classes for your messages add ScalaPB's sbt plugin to your project. Create a file named project/protoc.sbt containing the following line:

addSbtPlugin("com.thesamet" % "sbt-protoc" % "0.99.18")

libraryDependencies += "com.thesamet.scalapb" %% "compilerplugin" % "0.7.4"

Add the following line to your build.sbt:

PB.targets in Compile := Seq(
  scalapb.gen() -> (sourceManaged in Compile).value

For additional configuration options, see ScalaPB SBT Settings documentation

Using ScalaPB

Documentation is available at ScalaPB website.


ScalaPB uses ScalaCheck to aggressively test the generated code. The test generates many different sets of proto files. The sets are growing in complexity: number of files, references to messages from other protos, message nesting and so on. Then, test data is generated to populate this protocol schema, then we check that the ScalaPB generated code behaves exactly like the reference implementation in Java.

Running the tests:

$ sbt test

The tests take a few minutes to run. There is a smaller test suite called e2e that uses the sbt plugin to compile the protos and runs a series of ScalaChecks on the outputs. To run it:

$ ./