HomeJSON ConvertersJSON to Kotlin

JSON to Kotlin

Convert JSON to Kotlin data class.

Convert JSON to Kotlin data class.

This tool is designed to provide a seamless experience for developers by handling complex operations directly in your browser with maximum speed and security.

100% Private
Instant Results
Customizable
Offline Ready
Dev-Friendly
Easy Export

It converts JSON data into clean, idiomatic Kotlin data classes, specifically designed for use in modern Android and backend development. It intelligently identifies data types and creates the necessary class structure for working with JSON in Kotlin applications, including support for nested objects, arrays, and optional fields. The tool can also generate annotations for popular libraries like Moshi, Gson, or Kotlinx.serialization, making it easy to handle JSON data in your projects. Whether you are building an Android app with Jetpack Compose or a server-side service with Ktor or Spring Boot, this tool ensures that your Kotlin models are always correctly mapped to your JSON data structures.

Paste your JSON to generate Kotlin data classes. It includes `@SerializedName` annotations for Gson or `@SerialName` for Kotlinx Serialization.

Kotlin's concise syntax and type safety make it great for data models, but manually creating data classes for large and nested JSON structures can still be a repetitive and time-consuming task. This tool automates the creation of these classes, helping you maintain a structured and clean codebase for your Kotlin projects and significantly reducing the risk of mapping errors during development.

Example Input

{
  "id": 1,
  "name": "John Doe",
  "email": "john@example.com",
  "isActive": true,
  "tags": ["admin", "dev"],
  "profile": {
    "bio": "Software Engineer",
    "skills": ["Go", "React", "TypeScript"]
  }
}

Example Output

data class User(
    val id: Int,
    val name: String,
    val email: String,
    val isActive: Boolean
)

Library Specifics

Fix: The generated code might require a JSON library like Gson or Kotlinx Serialization. Ensure you have the correct library in your project.

Does it support default values?

Yes, you can choose to generate default values for optional fields in the data class.