ToolZoneX
Blog

JSON to Scala Case Class Converter

Paste a JSON sample to instantly generate matching Scala case classes with Option[Type] wrapping optional and nullable fields. Free online developer tool.

Paste JSON
Scala Case Classes
Scala case class definitions will appear here...

Free JSON to Scala Case Class Converter

Paste a JSON sample to instantly generate matching Scala case class declarations, withOption[Type] wrapping any field that's optional or nullable in your data.

How to Use It

Paste any JSON object or array, or click "Load Example." The tool infers a type shape and emits one case class per object level, with camelCase constructor parameters, nested objects pulled out into their own named case class, List[T] for arrays, andOption[Type] (defaulting to None) for any property that's missing ornull in your sample.

Example

Given {"name": "Ann", "age": 30, "tags": ["a","b"], "address": {"city": "NYC", "zip": null}}, the tool emits case class RootAddress(city: String, zip: Option[String] = None) and aRoot case class referencing it, with tags: List[String].

Common Use Cases

  • Modeling JSON payloads for circe, play-json, or spray-json in a Scala backend.
  • Bootstrapping immutable domain models from a sample API response.
  • Getting a starting point for Akka HTTP or Play Framework request/response types.

FAQs

Why does the generator use Option instead of nullable types?

Idiomatic Scala avoids null in favor of Option[T], which forces callers to explicitly handle the absent case. Any field that's missing from at least one sample or was evernull is wrapped in Option with a None default.

Will this work directly with circe or play-json?

The generated case classes are plain Scala and are exactly the shape both libraries expect for automatic derivation — you'll still need to bring the relevant codec/format derivation into scope for your library of choice.

Is my JSON uploaded anywhere?

No — parsing and code generation happen entirely client-side in your browser. Nothing you paste is sent to a server.