JSON to Kotlin Data Class Converter
Paste a JSON object to generate Kotlin data classes. Types are inferred for each field, and nested objects become their own data classes.
How to convert JSON to Kotlin data classes
- Paste a JSON object into the box.
- Set the root class name if you want something other than Root.
- Copy the generated Kotlin data classes into your project.
Examples
Object with a nested object
{"id":1,"address":{"city":"Oslo"}}data class Root(
val id: Int,
val address: Address
)
data class Address(
val city: String
)Frequently asked questions
Is my JSON uploaded anywhere?
No. The conversion runs entirely in your browser, so your data never leaves your device.
How are field types inferred?
Whole numbers become Int, fractional numbers Double, text String, true or false Boolean, and arrays List of the first item's type.
How are nested objects handled?
Each nested object becomes its own data class named in PascalCase after its key, and the parent references it by type.
What happens with a null value?
A null value is typed as the nullable Any?, since the concrete type cannot be inferred from null alone.
Why must the input be a JSON object?
Data classes model named fields, so the converter needs an object at the root. A bare array or value cannot become a data class.
Related tools
JSON to PHP Array
Convert JSON to a PHP array online. Paste JSON and get a clean array() or short [] literal with correct nesting, quoting and types. Runs in your browser.
JSON to Python Dict
Convert JSON to a Python dict online. Paste JSON and get a valid dict and list literal with True, False, None and proper quoting. Runs in your browser.
JSON Formatter
Format, validate and minify JSON online. Pretty-print with custom indentation, sort keys and catch syntax errors. Runs in your browser.
Air Fryer Converter
Convert any conventional oven recipe to air fryer settings. Lower the temperature by 25 F and cut the cook time by about 20 percent automatically.
Baking Pan Converter
Swap one baking pan for another and scale the batter to fit. Compares pan areas for round, square and rectangular pans and gives a batter scale factor.
Binary to Decimal
Convert binary to decimal online. Paste any binary number, with or without spaces, and get the exact base-10 value instantly. Runs in your browser.