JSON to Kotlin

Paste JSON and instantly get matching Kotlin data class declarations with nested classes and nullable-safe types.

Input JSON

Kotlin Output

Paste JSON and click Generate

Copied!

Summary

Paste JSON and instantly get matching Kotlin data class declarations with nested classes and nullable-safe types.

How it works

  1. Paste or type JSON into the input panel, or load a sample.
  2. Set a root class name (defaults to RootObject).
  3. Click Generate to parse the JSON and build Kotlin data classes.
  4. Nested objects become their own named data classes; arrays of objects are scanned across all items to detect optional fields.
  5. Fields that are missing from some items, or that hold null, become nullable properties with a null default.
  6. Click Copy to copy the Kotlin code to your clipboard.

Use cases

  • Scaffold data classes for a REST API response before writing a Retrofit or Ktor client.
  • Turn a sample config file into a typed Kotlin settings class.
  • Generate a starting model for kotlinx.serialization or Moshi without typing every field by hand.
  • Document a third-party API response shape as Kotlin types.
  • Check which fields are optional before writing null-handling logic by hand.
  • Speed up adding an Android or backend Kotlin model from sample JSON.

Frequently Asked Questions

Last updated: 2026-07-23 · Reviewed by Nham Vu