HomeJSON ConvertersJSON to Scala

JSON to Scala

Convert JSON to Scala case class.

Convert JSON to Scala case class.

This tool is designed to provide a seamless experience for developers by handling complex operations directly in your browser with maximum speed and security.

100% Private
Instant Results
Customizable
Offline Ready
Dev-Friendly
Easy Export

This tool transforms JSON into clean, idiomatic Scala code, generating case classes with precise type annotations. It handles nested structures by creating multiple case classes and uses standard Scala types for accurate data mapping, making it ideal for functional programming and distributed systems. The tool can also generate JSON formatters and decoders for popular Scala libraries like Circe, Play-JSON, or uPickle, ensuring that your Scala models are consistent with your data sources and easy to manage throughout your project. By automating the mapping process, it promotes better functional design and type-safe data handling in your Scala applications.

Paste your JSON to generate Scala case classes. It can also generate JSON formatters for libraries like Circe or Play JSON.

Scala case classes are perfect for modeling immutable data, but manually defining them for large and complex JSON responses can be a tedious and repetitive task. This tool handles the work of mapping types and creating structure, providing you with a clean, typed foundation that integrates seamlessly with modern Scala libraries, saving you significant development time and reducing potential errors.

Example Input

{
  "id": 1,
  "name": "John Doe",
  "email": "john@example.com",
  "isActive": true,
  "tags": ["admin", "dev"],
  "profile": {
    "bio": "Software Engineer",
    "skills": ["Go", "React", "TypeScript"]
  }
}

Example Output

case class User(
  id: Int,
  name: String,
  email: String,
  isActive: Boolean
)

Library Specifics

Fix: The generated code might require a JSON library like Circe. Ensure you have the correct dependencies in your `build.sbt`.

Does it support Option types?

Yes, fields that are null in the JSON are automatically mapped to `Option[T]` in Scala.