Paste Scala on the left and click "Convert" — we will turn it into JSONPaste Scala code

What this tool does

If you have a Scala case class with a dozen fields and you need a matching JSON payload — for a test, an API call, a Kafka message fixture — building it by hand gets old fast. Paste the Scala here and you get back valid JSON. One case class, a file full of them, or a full instance constructed with named arguments — same flow, same result.

The converter matches what the common Scala JSON libraries produce. Circe, Play JSON, and uPickle all serialize a case class by turning its fields into JSON keys — that is exactly what you get here. Int, Long, Double, and BigDecimal become JSON numbers. Boolean stays a boolean. Option[A] becomes the value when Some(x), or null / omitted when None. Instant, LocalDateTime, and java.time types come out as ISO-8601 strings.

Collections follow the obvious mapping. List, Seq, Vector, and Set all become JSON arrays. Map[String, A] becomes a JSON object. Tuples become JSON arrays of mixed values. If you paste a sealed trait with case-class children (an ADT), each variant serializes as its own shape, and the parser picks up the ADT discriminator pattern used by most libraries. Paste multiple top-level classes from a single file (see the Scala repo for inspiration) and each becomes its own JSON entry.

How to use it

Three steps. Works the same for a single case class or a whole model file.

1

Paste your Scala (or try the sample)

Drop your Scala into the left editor as-is. A case class, a sealed trait hierarchy, an instance, or multiple classes — all fine. Click Load Sample if you want a realistic example first.

Keep your imports, package declarations, and annotations. The parser ignores what is not data. For language specifics, docs.scala-lang.org is the authoritative reference.

2

Hit Convert

Click the green Convert button. The tool reads the Scala, walks every class and field, and produces JSON in one pass. A short loading indicator shows while it runs.

3

Copy the JSON

The right panel fills with indented JSON. Drop it into a ScalaTest spec, a mock Akka HTTP response, a Play fixture, or your API documentation.

When this actually comes in handy

ScalaTest fixtures

You need a JSON body to stub an HTTP client in a Scala service test. Paste the case class, get the payload, drop it into your spec.

Akka / Play HTTP payloads

Turn a case class into the JSON you would POST to your own service. Useful for quick curl tests when wiring up a new endpoint.

Kafka message samples

Generate sample JSON messages for a new Kafka topic straight from your domain case classes — no hand-rolled examples that drift over time.

Docs that match the code

Produce JSON examples for API documentation directly from your actual case classes, so the docs stay accurate as models evolve.

Common questions

How are Option values serialized?

Some(x) becomes the value x; None becomes JSON null. That matches Circe's default behaviour. If you prefer omitted keys for None, you can strip them after the fact — the safe default keeps the shape predictable.

What about sealed traits and ADTs?

Sealed traits with case-class children serialize per variant. The common discriminator pattern ({"type": "OrderPlaced", ...}) used by Circe and Play JSON is applied when multiple variants share a parent trait, so you can round-trip the data back into the ADT.

How does it handle java.time types?

Instant, LocalDate, LocalDateTime, and ZonedDateTime are serialized to ISO-8601 strings. That is the convention shared by Circe, Play JSON, and uPickle, and it round-trips cleanly back into java.time.

Does it handle Map, List, Vector, Set?

Yes. List, Seq, Vector, and Set all become JSON arrays. Map[String, A] becomes a JSON object — non-string-keyed maps (Map[Int, A]) are emitted as arrays of key/value pairs, since JSON only supports string keys.

Can I paste a whole file with several case classes?

Yes. Each top-level class becomes its own JSON entry, with nested instances expanded. Companion objects, implicit conversions, and helper methods are skipped — only data makes it into the output.

Is my code stored?

Your Scala is sent to the backend for conversion and is not persisted. We do not log the payload. If the code is sensitive, give it a look before pasting.

Other tools you may need

Scala to JSON is one piece. These pair well with it: