What is JSON to Scala Play JSON Generator?
This tool converts JSON data into Scala case class definitions with optional Play JSON Format or Circe Encoder/Decoder instances. It automatically infers Scala types from JSON values, converts field names to camelCase, generates properly structured case classes with nested support, and produces the corresponding JSON serialization boilerplate for your chosen framework.
How to Use
- Set the root class name, package name, and choose a framework (Plain, Play JSON, or Circe)
- Toggle Option types for nullable fields as needed
- Paste your JSON data into the input area
- Click "Generate" and copy the output into your Scala project
Why Use This Tool?
Tips & Best Practices
- Use realistic sample data — type inference depends on actual values
- Enable Option types for idiomatic Scala null handling
- Nested objects become separate case classes with PascalCase names
- Null values in JSON are wrapped in Option[T] with default = None
- Select Play JSON for Play Framework projects, Circe for functional Scala projects
- Large integers exceeding Int range (2,147,483,647) are automatically typed as Long
Frequently Asked Questions
What is Play JSON?
Play JSON is the JSON library included with the Play Framework for Scala. It provides Reads, Writes, and Format type classes for converting between Scala objects and JSON. Format combines both Reads and Writes into a single type class for bidirectional conversion.
How are JSON types mapped to Scala?
JSON strings map to String, integers map to Int (or Long for large values), floats map to Double, booleans map to Boolean, null maps to Option[T] when enabled, arrays map to List[T], and nested objects map to separate case classes.
What about Option types?
When Option types are enabled, nullable JSON fields (those with null values) are wrapped in Option[T] with a default value of None. This is the idiomatic Scala way to handle nullable values and prevents NullPointerException errors.
Can I use this with Circe?
Yes! Select the Circe framework option to generate implicit Encoder[T] and Decoder[T] type class instances instead of Play JSON Format instances. Circe is a popular functional JSON library for Scala that uses type classes for serialization.
Is my data sent to a server?
No, all processing happens entirely in your browser. Your JSON data never leaves your device.