Paste JSON, get Scala case classes. Nested objects become child classes, arrays become List, null becomes Option, all in your browser.
- Runs locally
- Category Format Converter
- Best for Turning pasted content or local files into a handoff-friendly format.
How types, child classes & Option are inferred
Each JSON object becomes a named case class with camelCase fields. Integer numbers infer Int (Long when they overflow a 32-bit Int); fractional numbers infer Double; a field that is whole in one sample and fractional in another widens to Double. Nested objects are pulled out into their own child case class named ParentKey (user.address becomes UserAddress). Arrays of objects fold into ONE class so you get a single List[T], not N near-duplicates; keys missing from some elements become Option[T] when "Option" is on. A value that is only ever null types as Option[Any]. Toggle Seq[T] if your codebase prefers the immutable Seq alias over List.
What this tool does
Paste any JSON payload, a Play Framework request body, an Akka HTTP response, a Spark config, a sample from some upstream API, and get back a clean set of Scala `case class` declarations ready to drop into a `.scala` file. Each JSON object turns into its own named case class; nested objects are pulled out into child classes named after the parent and the key, so `user.address` becomes `UserAddress` instead of an anonymous inline blob. Numbers are split rather than flattened: an integer sample infers `Int`, a value past the 32-bit range infers `Long`, and a fractional sample infers `Double`. Arrays of objects fold into ONE case class so `[{a:1},{a:1,b:2}]` gives a single `List[T]` with `b` marked optional, not two near-duplicate types. Keys that show up as `null` or are missing from some array elements become `Option[T]` when you keep the Option toggle on, which is the idiomatic way to model nullable JSON in Scala. Switch arrays to `Seq[T]` if your codebase prefers the immutable Seq alias, rename the root class, and copy or download the result. Everything runs client-side, so the JSON you paste never touches a server.
Tool details
- Input
- Text + Numbers + Structured content
- The page exposes text boxes, numeric controls, file pickers, or structured inputs depending on the tool.
- Output
- Live result + Copy + Download
- The result area focuses on usable output, with copy, download, or preview actions when supported.
- Privacy
- Browser-side processing
- The main tool logic does not call an external API, so inputs normally stay in the current tab.
- Save / share
- Shareable URL state
- Key settings are encoded in the URL so another person can reopen the same setup.
- Performance budget
- Initial JS <= 9 KB
- No WASM budget is declared, keeping the tool quick to open on mobile.
- Best fit
- Format Converter · Developer
- Category and role tags drive related tools, internal links, and quick fit checks.
How to use
-
1. Input
Paste or drop your content into the tool panel.
-
2. Process
Click the button. All processing is local in your browser.
-
3. Copy / Download
Copy the result or download to disk in one click.
How JSON to Scala fits into your work
Use it when the main problem is getting content from one practical format into another.
Conversion jobs
- Turning pasted content or local files into a handoff-friendly format.
- Previewing a conversion before you use it in a larger workflow.
- Cleaning small format mismatches without opening a full editor.
Conversion checks
- Try a small sample first when the source format is messy.
- Check character encoding, separators, and line endings after conversion.
- Keep the source until the converted output has been reviewed.
Good next steps
These links move the current task into a more complete workflow.
- 1 JSON to Kotlin Data Class JSON to Kotlin data class — paste JSON, get val properties, camelCase fields, nullable T?, nested classes, and kotlinx.serialization @SerialName, Gson @SerializedName, or Moshi @Json annotations. Open
- 2 JSON to Rust Struct JSON to Rust struct — paste JSON, get serde-derived structs with snake_case fields, serde rename, Option for nullable, Vec for arrays, nested sub-structs. Open
- 3 JSON to Go Struct JSON to Go struct — paste JSON, get typed structs with json tags, exported fields, nested sub-structs, pointers for nullable, int64 and omitempty options. Open
Real-world use cases
Model a third-party API response without hand-writing classes
You are integrating an upstream service and its user object has 25 fields across a couple of nested objects. Hit the endpoint once, paste the JSON, set the root name to `ApiUser`, and copy the output into your model file. The nested `profile` object lifts out as `ApiUserProfile` on its own, and the array of `roles` becomes a typed `List[ApiUserRole]` instead of a raw `Map[String, Any]` you would otherwise pattern match by hand.
Generate request and response models for a new endpoint
A teammate sends a sample JSON body for the `/orders` POST they are building. Paste it, name the root `CreateOrderRequest`, and keep Option on so the fields they marked optional come through as `Option[T]`. Paste the response sample too as `CreateOrderResponse`. Two case classes, fully typed, committed to your DTO file before either of you writes the route.
Build circe or play-json decoders faster
Writing circe codecs by hand starts with the case class. Paste the sample payload, generate the case class, then add `deriveDecoder[ApiUser]` next to it. Because nullable and missing fields already come through as `Option[T]`, the derived decoder handles absent keys without throwing, and you skip the round of runtime failures that come from forgetting one optional field.
Turn a config file into typed Scala
Your service reads a `config.json` with a server block and a tls block inside it. Paste it, name the root `Config`, and get `Config`, `ConfigServer`, and `ConfigServerTls` as nested case classes with `Int` ports and `Boolean` flags. Drop them into your config module and decode once at startup, so a typo in a key fails at decode time with a clear path rather than deep inside a request later.
Common pitfalls
Pasting a single object and expecting some fields to be optional. A single object has no missing-key signal, so every field is required. Option inference only kicks in across an array of objects where some elements carry a key and others do not. To explore optionality from one sample, wrap it as `[{...}]`.
Forgetting that a field seen only as null becomes `Option[Any]`. The value `{"meta": null}` yields `meta: Option[Any]` because null carries no type information. If you know the real shape, paste a non-null sample like `{"meta": {"k": 1}}` so the tool can infer a proper child case class.
Pasting JSON5, JSON with comments, or trailing commas. The tool uses strict `JSON.parse`, so comments, unquoted keys, and trailing commas all error out with a line and column. Strip them first, or run the payload through a JSON formatter as a pre-step.
Privacy
Your JSON never leaves this browser tab. Parsing and type inference use the browser built-in `JSON.parse`, with no network call and no analytics on the textarea content. The Share link encodes your input and option choices into the URL so a result is reproducible, which means you decide when to share. If the payload is sensitive, such as internal IDs or production responses, copy the generated Scala instead of sharing the link. Only your option booleans, Option and Seq, are stored in localStorage so your preferred style persists across visits.
FAQ
Tool combos
Folks in your role tend to reach for these alongside this tool.
- 555 Timer Calculator Astable f = 1.44/((R1+2R2)C) + monostable t = 1.1RC — pick R1, R2, C in Ω/kΩ and µF/nF, read frequency, duty cycle and pulse width — browser-only
- Add Line Numbers Number every line of pasted text — set start, step and separator, zero-pad to align, skip blanks, or strip numbers back off — browser-only
- AES Text Encryptor Encrypt & decrypt text with a password — AES-256-GCM + PBKDF2 via WebCrypto — 100% in your browser, nothing uploaded
- Affine Cipher Encoder & Decoder Encrypt and decrypt the ax+b affine cipher with live modular-inverse check, browser-only