JSON to Kotlin

Convert JSON to Kotlin data classes online. Nullability with ?, nested data classes, val properties.

Generated code will appear here...

Everything runs locally in your browser. Your JSON is never uploaded or stored.

What is a JSON to Kotlin converter?

A JSON to Kotlin converter generates idiomatic data classes from JSON samples: immutable val properties, nullable types with defaults, and nested classes named after their keys. Great for Android and JVM API models.

How to generate data classes

Paste a JSON object, optionally rename the root class, and copy the result. All classes are emitted together so you can paste them into one file.

Types and nullability

String, Int, Double, and Boolean are inferred from the sample; collections become List<T>. Anything optional or null becomes T? = null.

Nesting and naming

Nested objects become their own data classes with names derived from the parent, e.g. address inside Root becomes RootAddress — collisions get numeric suffixes. Keys that differ beyond casing from the property name receive an explicit annotation.

Frequently Asked Questions

How do I convert JSON to Kotlin data classes?+
Paste your JSON and each object becomes a Kotlin data class with val properties. Nested objects become their own data classes and arrays become List<T>.
How is nullability handled?+
Fields that can be missing or null are typed T? with a default of null, e.g. val nickname: String? = null, matching safe Kotlin idioms.
Which serializers does the output work with?+
The generated data classes work with kotlinx.serialization, Moshi, and Gson. When a key does not map to a valid property name, a Jackson @JsonProperty annotation keeps the mapping explicit.
Is my JSON uploaded?+
No. Everything runs locally in your browser and nothing is stored.

Related Tools

JSON to Kotlin — free online json to kotlin, json to data class, kotlin data class from json, json to kotlin converter, generate kotlin from json, kotlin data class generator, json to kotlin online, kotlin models from json, convert json to kotlin data classes, json to kt. No signup required. Works in your browser.