CODDY Tool

JSON to Kotlin

Turn a JSON sample into Kotlin type definitions.

Paste a JSON response and get Kotlin types back. Every element of an array is merged, so fields missing from some objects come out optional rather than required.

Everything you enter stays in this browser tab. Nothing is sent to our servers, logged or stored.

This is one of the thingsJSON Type Generatordoes — open it for everything else it supports.

Loading tool…

What JSON Type Generator supports

  • TypeScriptExported interfaces.
  • GoStructs with json tags.
  • KotlinData classes.
  • SwiftCodable structs.
  • PythonDataclasses.
  • C#Classes with properties.

About JSON to Kotlin

Kotlin data classes map onto JSON objects neatly, and its null safety makes the optional-versus-nullable distinction something the compiler enforces rather than something you remember.

Fields missing from some array elements are emitted as nullable with a default of null, so deserialising an object that lacks them succeeds instead of throwing. Getting this wrong is the usual cause of a crash on a response that was perfectly valid.

Keys that are not valid Kotlin identifiers are camel-cased and given a @SerialName annotation carrying the original key, so the renamed property still reads the right value.

How to generate Kotlin types

  1. Paste your JSON

    A whole array is better than one object — more samples means a more accurate type.

  2. Name the root type

    Nested objects are named automatically from the keys that hold them.

  3. Copy the definitions

    Types are emitted children first, so the file compiles in order.

Frequently asked questions

Why is a field optional when my sample has it?

Because at least one object in the array you pasted was missing it. That is a real difference in the data, and a type that marks it required would compile and then fail at runtime on the object that lacks it.

Why did a field come out as unknown?

Because the same key held genuinely different types across your samples — a number in one object and a string in another. There is no single type that describes both, so widening to unknown is the honest answer.

Does it handle nested objects?

Yes. Each nested object becomes its own named interface, named after the key holding it, and a key holding an array is singularised — users produces a User rather than a Users.

Is my JSON uploaded anywhere?

No. Everything is parsed and generated in this browser tab, which matters when the sample is a response from an unreleased API.

All Developer Tools

JSON to Kotlin is free to use with no account, no watermark and no usage limits. Last updated 14 August 2026.