JSON Input

Scala Output

What Is JSON to Scala?

Scala uses case classes for structured data. When you consume JSON with Circe or Play JSON, you need matching case class definitions. The JSON specification defines objects, arrays, strings, numbers, and booleans—but Scala needs explicit definitions for each nested object.

This tool generates Scala case classes from your JSON. Enable Case Class for immutable data. Enable Option Types for optional fields. The output works with Circe, Play JSON, or json4s.

Conversion runs entirely in your browser. Your JSON is never sent to a server.

When JSON to Scala Helps

When building Scala or Akka apps that consume REST APIs, you need typed case classes. Paste a sample response here to generate matching classes.

How to Use This Tool

1

Paste or Upload JSON

Copy your JSON and paste it into the left editor. You can also click Upload to load a file. Use the Sample button for example data. Set the case class name and options in the config panel.

2

Review the Generated Classes

The right panel shows the generated Scala case classes. Nested objects become separate case classes. Arrays become <code>List[T]</code>. If your JSON has invalid syntax, fix it first using the JSON Formatter or JSON Validator.

3

Copy or Download

Use Copy or Download to get the code. Paste into your Scala project. Add Circe or Play JSON to your build for JSON parsing.

JSON to Scala Examples

Here is an example of generating Scala case classes from a JSON object.

Example: Subscriber record

JSON input:

Input

Generated Scala output:

Output

When JSON to Scala Helps

Most developers need this when integrating with REST APIs. Pasting it here gives you case classes you can use with Circe or Play JSON.

If you need to merge two JSON files first, there's a separate JSON Merge tool for that.

API responses, config files, or data exports are often JSON. Running them through here helps you generate Scala case classes.

Frequently Asked Questions

Case class vs regular class?

Case classes are immutable by default and provide equals, hashCode, and copy. They work well with Circe and Play JSON for JSON parsing.

What about Option for null fields?

Enable Option Types for optional JSON fields. This wraps nullable fields in Option<T>.

Is my data sent anywhere?

No. Generation runs entirely in your browser. No data is sent to any server.

Can I use with Circe?

Yes. The generated case classes work with Circe's Decoder and Encoder. Add io.circe %% "circe-generic" for automatic derivation.

What about nested objects?

Nested JSON objects become separate Scala case classes. Arrays become List[T] of those case class types.

Related Tools

For Scala JSON, see Circe and Play JSON. For JSON, see the JSON specification.