JSON to Kotlin
Paste JSON and instantly get matching Kotlin data class declarations with nested classes and nullable-safe types.
Use the JSON to Kotlin
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
- Paste or type JSON into the input panel, or load a sample.
- Set a root class name (defaults to RootObject).
- Click Generate to parse the JSON and build Kotlin data classes.
- Nested objects become their own named data classes; arrays of objects are scanned across all items to detect optional fields.
- Fields that are missing from some items, or that hold null, become nullable properties with a null default.
- 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-09-19 ·
Reviewed by Nham Vu