Free · No sign-up · Runs in your browser

JSON to Kotlin Data Class Converter

Generate Kotlin models for kotlinx.serialization with nested classes, SerialName mappings, nullable types and defaults for missing fields.

STEP 1

Start with your input

Edit the example or replace it with your own text.

How to use JSON to Kotlin Data Class Converter

  1. Paste a JSON object or a non-empty array of example objects.
  2. Generate Kotlin models using every example to infer missing and nullable properties.
  3. Configure the Kotlin serialization plugin and kotlinx-serialization-json in your own project before using the generated classes.

Model the response without renaming its JSON keys

Properties use generated camelCase names and SerialName annotations to retain the original key. Strings, booleans, Int, Long, Double and List types are inferred from samples. Nested objects receive their own serializable model. Mixed shapes use JsonElement, and empty objects use an ordinary class because Kotlin data classes require at least one constructor property.

Keep required-nullable and missing fields distinct

A field that is present with null is nullable but still has no default when all samples contain it. A field absent from some records gets a nullable type with a default of null. These are sample-derived choices, not a complete API specification. Strings resembling dates stay String. Review enum constraints and validation separately, and keep numeric IDs as strings when they exceed safe browser JSON integer precision.

Example input

[{"user_id":1,"profile":{"name":"Ada"},"tags":["admin"]},{"user_id":2,"profile":null}]

Does this configure Gradle or the serialization compiler plugin?

No. It generates model source. Your project must supply the serialization plugin and libraries appropriate to its Kotlin version.

Is input uploaded?

Processing takes place in your browser. This tool does not send your input or selected files to a conversion API.

Related tools and guides

Browse all developer tools