🔄 JSON to Kotlin Data Class

One-click convert JSON data to Kotlin data class definitions with nested classes and nullable types

Zero Dependencies · Works Offline

📝 JSON Input

What is JSON to Kotlin Data Class Converter?

The JSON to Kotlin Data Class Converter is a free online developer tool that instantly converts JSON data into Kotlin data class definitions. It automatically identifies JSON field types and maps them to Kotlin types, supporting nested object class generation, Gson/Moshi/Kotlinx Serialization annotations, and nullable type handling. Perfect for Android and Kotlin backend developers who need to quickly generate data class definitions from API responses, dramatically reducing manual coding. All conversion happens locally in your browser — no data is ever uploaded to a server.

Core Features

How to Use

1. Paste your JSON data into the input area, or click "Load Example" to try it quickly.

2. Set the class name and conversion options: annotation type, nullable types, integer types.

3. Click "Convert" or use Ctrl+Enter to execute.

4. View the generated Kotlin data class code in the result area below.

5. Click "Copy Code" to copy to clipboard, or download as a .kt file.

Use Cases

Android Development

When integrating REST APIs, paste the JSON response to instantly generate data classes with Gson annotations, saving manual coding time.

Kotlin Backend

Ktor or Spring Boot developers can quickly generate data classes from request body JSON samples, accelerating API development.

Data Model Definitions

In Kotlin Multiplatform projects, quickly generate platform-specific data class definitions from shared JSON schemas.

Project Migration

When migrating from Java to Kotlin, quickly convert existing JSON models to Kotlin data classes.

Technical Background

Kotlin data classes are specifically designed for holding data, automatically generating equals(), hashCode(), toString(), and copy() methods — more concise and safer than Java POJOs. In Android development, Gson is the most popular JSON library, using @SerializedName to map JSON field names to Kotlin properties. Moshi by Square is a modern alternative with better Kotlin support via @Json. Kotlinx Serialization is JetBrains' official solution with compile-time code generation for better performance, using @SerialName. Nullable types (Type?) are a key Kotlin feature that precisely distinguishes null and non-null values, preventing NPEs.

âť“ FAQ

Does it support nested JSON?

Yes. Nested objects are automatically generated as separate data classes with their own type names.

How are null values handled?

With "Nullable types" enabled, null fields generate nullable types (e.g., String?). Disable for non-null types with defaults.

Does it support arrays?

Yes. JSON arrays convert to Kotlin List<T>, where T is inferred from element types.

Is my data uploaded?

No. All processing happens locally in your browser. Your data never leaves your device.

What annotations are supported?

Gson @SerializedName, Moshi @Json, and Kotlinx Serialization @SerialName.

Can generated code be used directly?

Yes. The output follows Kotlin conventions and can be copied directly into a .kt file.

JSON to Kotlin Data Class Converter | No Signup, Client-Side · No Server Uploads

Feedback: dexshuang@google.com