One document, or several samples as JSON Lines.
Options for Kotlin

Convert JSON to Kotlin data classes

Paste a JSON sample and get Kotlin data classes: String, Long, Double, Boolean, List<T>, nested classes, nullable types with = null for fields some records lack, and @SerialName where a key isn't a camelCase name. Turn off kotlinx.serialization under Options for plain data classes.

It runs entirely in your browser; nothing is uploaded.

Need a different language? See all JSON-to-code converters.

JSON to Kotlin Data Class Converter — frequently asked questions

Does it work with Moshi or Gson instead?
The data classes do; turn off the kotlinx.serialization annotations under Options and add your library's own (@Json(name = ...) or @SerializedName) where @SerialName would have been.
What if some records have fields that others don't?
Every item of every array and every sample is read, not just the first. A field missing from some records comes out optional, a field holding two kinds of value becomes a union (or the language's any-value type), null beside a value makes it nullable, and a list of records at the top level gets an item type plus an alias for the list. Paste several samples as JSON Lines, one per line, and they're merged the same way.
Is my JSON uploaded anywhere?
No. Parsing and code generation run entirely in your browser with JavaScript — your JSON never leaves your device, so it's safe to paste API responses and other sensitive payloads. It's free with no sign-up.

Spotted a bug or have a suggestion?

Found something broken, have an idea, or just want to say thanks about any of our tools? Every message reaches a real person.