JSON to Kotlin Data Class Generator (Kotlinx, Moshi, Gson & Jackson)

Generated Kotlin Data Classes
3
Data Classes
15
Total Properties
29
Code Lines
Technical Reference & Architecture Guide

JSON to Kotlin Data Class Generator Developer Guide — Reference Guide

Comprehensive reference for converting arbitrary JSON structures into idiomatic Kotlin data classes with Kotlinx.serialization, Moshi, Gson, Jackson, and null-safety.

Key Parameters & Controls

rootClassNamestring

Name given to the root Kotlin data class representing the top-level JSON structure.

serializationLibrarystring ('kotlinx' | 'moshi' | 'gson' | 'jackson')

Target serialization framework used to generate property annotations.

nullSafetyboolean

Infer nullable types (Type?) with default null values for unpopulated or missing fields.

immutabilitystring ('val' | 'var')

Declare properties as immutable (val) or mutable (var).

Pro Tips & Best Practices

Prefer 'val' properties with default values in Kotlin data classes to ensure immutability and easy copying with .copy().

In modern Android projects, use Kotlinx.serialization (@Serializable and @SerialName) for official Jetpack Compose compatibility.

Map ISO 8601 timestamps to java.time.Instant or kotlinx.datetime.Instant for robust cross-platform date handling.

Common Gotchas & Troubleshooting

The generator wraps colliding identifiers in backticks (`is`, `object`) or attaches a library-specific serialization annotation.

Provide a sample JSON array with at least one representative item so the inner data class can be inferred.

Frequently Asked Questions

Which annotations are added for Kotlinx.serialization?▼

The class receives @Serializable and properties with different casing receive @SerialName('...').

Are nested JSON objects decoupled into separate data classes?▼

Yes. Sub-objects are cleanly defined as separate, modular data classes.

How are integer and floating point numbers differentiated?▼

Whole numbers are inferred as Int (or Long if large) and numbers with decimal points are inferred as Double.

Is my data sent to any third-party API during conversion?▼

No. The entire AST parser and Kotlin code generator operate 100% on the client side in JavaScript.

Related Tools & Utilities

All Tools →