TFT

JSON to Kotlin Data Class Generator

Generate Kotlin data classes with nullable and non-nullable fields from JSON. Our free tool helps Android and Kotlin developers create accurate data models in seconds.

About JSON to Kotlin Converter

Android developers need data classes to parse JSON responses. This tool generates Kotlin data classes from your JSON with proper types and nullable fields. It handles nested objects, arrays, and creates separate classes for complex structures.

How the conversion works

Paste your JSON and set the class name and package. Click Convert to Kotlin and the tool analyzes your structure, infers types, and generates data classes with primary constructors. Nested objects become separate data classes.

The output uses Kotlin types: String, Int, Double, Boolean, and List. Nullable fields are marked with question marks. Use Copy to grab the code or Download to save as a .kt file for your Android project.

When you'd use this

You're building an Android app that consumes a REST API. Or you received JSON from backend and need Kotlin models quickly. This tool also helps when exploring an unfamiliar API and you want to understand the data structure.

Generated classes are a starting point. You may need to add serialization annotations, custom serializers, or validation. For production code, consider using libraries like kotlinx.serialization or Moshi.

Questions

Does this handle nested JSON?

Yes, nested objects become separate data classes. The tool generates all necessary nested classes automatically.

Are fields nullable by default?

Fields that could be null based on the JSON are marked as nullable with the question mark suffix.

Can I set a custom package name?

Yes, use the Package Name input to set your Android app's package. The default is com.example.

Does it support data class defaults?

No default values are generated. All fields are required constructor parameters in the data classes.

What about JSON serialization?

The generated classes are plain data classes. Add @Serializable or @Json annotations based on your chosen library.