Convert JSON to Kotlin data classes for kotlinx.serialization, Jackson or Gson
A free JSON to Kotlin converter: paste JSON and get data classes back instantly. Choose immutable val properties or mutable var ones, and pick the JSON library the annotations target: kotlinx.serialization (@SerialName), Jackson (@JsonProperty) or Gson (@SerializedName). Property types are inferred from the data, nested objects become their own classes, and keys that can be null or missing become nullable properties with a null default. Conversion runs entirely in your browser, so your JSON is never uploaded to a server.
Output formats: Data class (Immutable data class with val properties), Mutable (Data class with var properties).
| Option | What it does |
|---|---|
| Root Class Name | Names the top-level Data class. |
| Package (optional) | Emitted as a package declaration at the top of each file. |
| Field Naming Convention | One of camelCase, PascalCase, snake_case, Preserve Original. Defaults to camelCase. |
| Type for null values | Either Any (JsonElement for kotlinx) or String, used when a key is null in every sample. |
| Separate Classes | Write each class to its own .kt file. Off (the default) puts every class in one file, so Copy All pastes into a single file that compiles. |
| Add JSON annotations | Annotate properties with the original JSON key — @SerialName, @JsonProperty or @SerializedName, depending on the library. Without them a property only binds to a key spelled exactly like it, so snake_case keys are not read into camelCase properties. |
| JSON library | One of kotlinx.serialization, Jackson or Gson; picks which JSON library the generated code is written for. |
| JSON value | Kotlin type |
|---|---|
| string | String |
| integer | Int |
| integer beyond 32 bits | Long |
| decimal | Double |
| true / false | Boolean |
| ISO-8601 timestamp | String |
| array | List<T> |
| object | nested data class |
| null or missing in some samples | T? = null |
| null | Any? / JsonElement? (configurable) |
{
"id": 12345,
"product_name": "Wireless Mouse",
"price": 24.99,
"in_stock": true,
"tags": ["electronics", "accessories"],
"manufacturer": {
"name": "Acme Corp",
"country": "US"
}
}
@Serializable
data class Product(
@SerialName("id") val id: Int,
@SerialName("product_name") val productName: String,
@SerialName("price") val price: Double,
@SerialName("in_stock") val inStock: Boolean,
@SerialName("tags") val tags: List<String>,
@SerialName("manufacturer") val manufacturer: Manufacturer
)
Paste your JSON into the input pane and the Kotlin data classes appear beside it immediately. Pick the JSON library, set the root class name and an optional package, then copy the code or download it. Nested JSON objects become their own data classes and arrays become List<T>.
kotlinx.serialization is the Kotlin-native choice and works on every Kotlin platform; the classes are marked @Serializable and properties use @SerialName. Jackson (with jackson-module-kotlin) and Gson are the usual picks in existing JVM and Android code; they emit @JsonProperty and @SerializedName. The properties are identical apart from the annotation.
A key that is null or missing in at least one sample becomes a nullable property with a null default, so a payload that omits it still deserializes. A plain non-null property makes kotlinx.serialization and Jackson throw on a missing key, and Gson silently leaves it null.
kotlinx.serialization has no built-in java.time serializer and Gson cannot reflect into java.time on recent JDKs, so there is no date type that works with all three libraries without extra modules or adapters. A String always round-trips exactly; parse it with java.time or kotlinx-datetime where you need a date.
No. Parsing, type inference, and code generation all run in your browser using JavaScript. Your JSON is never sent to a remote server, and there is no account to create. The page keeps your last input and settings in your own browser (localStorage) so they survive a reload; nothing is stored anywhere else.
The conversion itself never transmits your JSON, so a confidential payload does not leave your machine. You can verify this: open your browser DevTools, switch to the Network tab, and convert something — no request carries your data. Two things to know: your last input is saved in your browser's localStorage (clear site data to remove it), and the Copy Link button embeds your JSON in the link, so anyone who opens that link, and the server that receives the request, can see it. Only share such links where you are comfortable with that.
No. The generator is free to use with no sign-up and no usage limits.
Each nested JSON object becomes its own named type, derived from the key it appeared under. Arrays of objects are widened across every element, so a field that is a whole number in one element and a fraction in another gets a type that holds both.