Skip to content
ToolsOnDuty - free online tools
Developer Tools

JSON to Kotlin Data Class

Convert JSON into Kotlin data classes for Android apps.

Free browser toolRuns in your browserNo sign-up
Kotlin model generator

Turn representative JSON into Kotlin models

Infer nested types and generate a copy-ready Kotlin data class starting from one realistic payload.

Kotlin

language

Root

root type

12 lines

output

Representative JSON

129 characters

Kotlin output

Generated locally

Types are inferred only from this sample. Null values become optional; verify optionality, coding keys and numeric ranges against the complete API contract.

Private by design. Input is processed inside this browser tab and is not sent to ToolsOnDuty.

About the JSON to Kotlin Data Class

Android apps map JSON responses to Kotlin data classes, often for use with Gson, Moshi or kotlinx.serialization.

This tool reads a JSON sample and generates Kotlin data classes, inferring types for strings, numbers, booleans, lists and nested objects.

Everything runs in your browser, so your JSON stays private.

Key features

  • Generates data classes from JSON
  • Infers Int, Double, Boolean, String, List and nested types
  • Custom root class name
  • Local, private conversion

How to use

  1. 1Paste a JSON sample.
  2. 2Set the root class name if you like.
  3. 3Copy the generated Kotlin data classes.

Examples

Simple model
Input: { "id": 1, "name": "Ada" }
Output: data class Root(val id: Int, val name: String)

Each JSON field becomes a typed val in the data class.

Frequently asked questions

Which serialization libraries does this suit?
The generated data classes work with Gson, Moshi and kotlinx.serialization. You may add annotations like @SerializedName or @Json for keys that are not valid Kotlin identifiers.
How are null values handled?
A null becomes a nullable String? since the real type cannot be inferred. Change it to the correct nullable type for your model.
Does it support nested objects?
Yes. Nested objects become their own data classes and arrays become typed Lists based on the first element.

Open a related tool to prepare your files or refine the finished result.