JSON to Kotlin data class
Turn a JSON sample into a ready-to-use Kotlin data class.
JSON to Kotlin data class
Paste a JSON response and this tool converts it into a ready-to-use Kotlin data class, inferring every field's type directly from the values you provide. It's built for Android and backend developers who need a quick model for an API response, a config file or a sample payload, without hand-typing property names and types or reaching for an IDE plugin.
Set a name for the root class, and choose how nested objects appear: nested inside the root class or declared as separate top-level classes. Switch between val for immutable properties and var when the model needs to be mutable, and turn on default values to give every property a sensible fallback (an empty string, zero, emptyList()) so instances can be created with fewer arguments. Add @Serializable and @SerialName annotations for kotlinx.serialization, or @SerializedName for Gson, and pick 2-space, 4-space or tab indentation to match your project's style.
Missing or null values become nullable types automatically, arrays become List<T> with the element type inferred from every item, and objects with the same shape are collapsed into one reused class instead of being duplicated. The "merge fields across array elements" option controls whether that item type is built from every element in the array or just the first one, which is useful for a very large or unevenly shaped array. When the JSON at the top level is itself an array, the tool wraps the inferred item type in a List for you.
Everything runs locally in your browser — your JSON is never uploaded or sent to a server, so it's safe to paste real API responses and internal payloads. Copy the generated Kotlin, download it as a .txt file, or send the output back into the input to convert it again with different options.