Gitignore Generator
Build a .gitignore from templates for your stack, editor and OS.
Generate Kotlin data classes with Gson or kotlinx.serialization annotations.
The JSON to Kotlin Data Class converter generates data classes with camelCase properties, an annotation carrying the original JSON key, and nullable types with defaults for keys that are not always present.
A Kotlin data class is the shortest way to model a payload, and this writes them for you: one per nested object, with the property names in camelCase and an annotation carrying the original JSON key.
Both serialisation libraries are supported. Gson mode emits SerializedName, which is what most existing Android projects use; kotlinx.serialization mode emits Serializable and SerialName, which is the multiplatform-friendly choice. Fields that are absent from some records are declared nullable with a null default, so deserialisation does not throw on a payload that legitimately omits them.
Gson's SerializedName for existing Android projects, or Serializable and SerialName for kotlinx.serialization and Multiplatform.
A key missing anywhere in the sample becomes a nullable property with a null default, so deserialisation does not throw on a partial payload.
Kotlin does not tie file names to type names, so the whole output can live in a single Models.kt.
equals, hashCode, toString and copy come free, which is exactly what a payload model needs and nothing more.
Long and Double are used because millisecond timestamps and database identifiers regularly exceed the 32-bit range.
An array of records detects optional fields better than one object.
Gson for most Android projects, kotlinx.serialization for Kotlin Multiplatform.
Nested classes take their names from their keys.
Paste into a .kt file — several data classes can share one file in Kotlin.
kotlinx.serialization if you are starting fresh: it is compile-time, reflection-free and works on Kotlin Multiplatform. Gson if the project already uses it, since mixing two serialisers is rarely worth it.
Because the sample showed them missing or null somewhere. Deserialising a missing key into a non-null property throws at runtime, so nullable with a default is the safe generated form.
Yes. Kotlin does not tie file names to type names, so the whole generated output can live in one Models.kt file.
Because JSON numbers frequently exceed the 32-bit range — millisecond timestamps and database IDs both do. Narrow to Int by hand where you know the range.
What people who use the JSON to Kotlin Data Class think of it. Reviews come from visitors and are posted as written.
No ratings yet
Yours would be the first.
0 reviews
Newest first
No reviews yet
Be the first to rate the JSON to Kotlin Data Class. It takes half a minute and no account.
Write the first reviewBuild a .gitignore from templates for your stack, editor and OS.
Convert Base64 back to hexadecimal, with your choice of separator.
Turn an SVG into a React component with the attributes React expects.
Make every editor agree on indentation, line endings and charset.
Build CSS keyframe animations and watch them run as you edit.
Convert between JSON arrays and NDJSON, one compact document per line.
Draw a grid layout and get the CSS, including named template areas.
Your browser, engine, platform, languages and what it supports.