JSON to Kotlin Data Class
Create kotlinx.serialization data classes from a sample JSON object.
Build Kotlin serialization models quickly
Kotlin data classes pair naturally with kotlinx.serialization, but a response with many nested keys still takes time to model. This tool parses a JSON object and emits Serializable data classes for every discovered object shape. Whole numbers map to Long, decimals to Double, booleans to Boolean, text to String, and arrays to List with an inferred member type.
The default sample creates data class User with userId as Long, name as String, and active as Boolean. A SerialName annotation preserves user_id even though the property uses Kotlin camel case. Nested objects receive their own data classes, and arrays of records reference a singularized child name so the output can be placed into an Android or server project with minimal editing.
How names, numbers, and nulls are handled
Inference describes the provided value rather than a complete schema. A null is emitted as nullable Any, and an empty array becomes List of Any because no element is present. The pasted JSON is processed only in your browser. Review nullable properties, defaults, and integer ranges against the real endpoint, particularly when generated models will decode partially populated responses.
Frequently Asked Questions
Which Kotlin serialization library does this target?
The output uses kotlinx.serialization with Serializable and SerialName imports.
Are snake-case keys converted to camel case?
Yes. The Kotlin property is camel-cased and SerialName preserves the original wire key.
Does the tool infer nullable fields?
It marks an explicit null as Any nullable, but optionality that is absent from the sample must be reviewed manually.
Browse the full set of free, private, in-browser tools.