Report

Help us improve this tool

JSON To Scala Case Class

Generate Scala case classes from JSON sample data with real-time browser-side conversion and customizable root class names.

O M T

Generate Scala case classes from JSON payloads

Scala services, Spark jobs, and Play applications often need typed models that match JSON payloads from APIs, message queues, or configuration files. Writing nested case classes by hand is slow and error-prone when field names or nesting change. This generator inspects a JSON sample and emits Scala case classes you can paste into your project.

What this tool does

Paste JSON in the input panel. The converter infers nested object shapes and outputs Scala case classes with field types mapped from your sample values. You can set the root case class name before copying the generated code.

Configuration options

  • Root Case Class Name: Rename the top-level case class generated from your JSON sample.

Common use cases

  • Bootstrap Akka HTTP or Play models from REST API responses.
  • Create starter case classes for Spark JSON parsing pipelines.
  • Document expected payload shapes for backend and data teams.
  • Compare inferred models against OpenAPI or JSON Schema contracts.

Related tools

Need Kotlin instead of Scala? Try the JSON to Kotlin generator. For TypeScript models, use the JSON to TypeScript POJO Generator or build runtime validators with JSON to Zod.

Frequently Asked Questions

Does my JSON leave the browser?

No. Conversion runs entirely in your browser. Your JSON is never uploaded to a server, which makes the tool safe for internal API samples and production-like fixtures.

Can I rename the root case class?

Yes. Use the Root Case Class Name field to control the top-level Scala case class name. Nested classes are inferred automatically from object keys in your JSON sample.

What happens with arrays in JSON?

Arrays are mapped to Scala collection types based on the element types found in your sample. If array items have mixed shapes, the generator reflects the union of observed structures.

Is the output production-ready?

Generated case classes are a strong starting point. Review optional fields, numeric precision, and naming conventions before committing models to a shared codebase.