ToolBuddy
In Browser

JSON to Kotlin

Infer Kotlin data classes from a JSON sample. Nested objects become named classes with kotlinx.serialization annotations. Keys missing from some objects in an array are optional. Conversion stays in the tab.

Runs in your browser. Nothing is uploaded.

0 characters · 0 lines

0 characters · 0 lines

About this tool

Infer Kotlin data classes from a JSON sample. Objects become @Serializable data classes. When the Kotlin name differs from the key, the property gets @SerialName. Keys missing from some objects in an array, and a JSON null next to a concrete value, become nullable with a null default. Whole numbers stay Long. Other numbers become Double.

How to use: paste JSON, copy the classes. A root array of objects is written as a comment that Root is List<RootItem>, plus the item class. Empty objects become Map<String, JsonElement> and empty arrays become List<JsonElement>. This is a starting point. It does not add methods, sealed types, or validation.

Example: {"id":1,"name":"Ada","address":{"city":"London"}} yields data class Root and data class Address. The snippet expects kotlinx.serialization. Related: JSON to Java for records, JSON to TypeScript for interfaces, JSON to Go for structs.

The sample stays in the tab. Nothing is uploaded. After the page loads, conversion works offline.

FAQ

Related Convert tools