# JSON to Kotlin Data Class Converter

> Convert JSON objects into strongly-typed Kotlin Data Class definitions and data models.

To convert JSON to Kotlin Data Class, paste your JSON payload above and specify the root type name. The generator creates clean, idiomatic Kotlin Data Class code definitions instantly in your browser without uploading your JSON data to external servers.

**URL:** https://convertto.tech/t/json-to-kotlin
**Category:** Data & Format Tools (https://convertto.tech/c/data-tools)
**Privacy:** Runs entirely in the browser; no upload
**Cost:** Free, no sign-up
**Last updated:** 2026-08-01

## Key facts

- **Privacy:** Runs entirely in your browser — nothing is uploaded
- **Cost:** Free, unlimited, no sign-up

## From a JSON sample to a Kotlin data class

A `data class` is the right container for a decoded payload. The compiler writes `equals`, `hashCode`, `copy` and `toString` from the constructor properties, which is exactly what a transfer object needs and nothing beyond it. Properties are emitted as `val`, so the model is immutable once built.

## What the serialiser still needs from you

- An annotation. The class is library-neutral as generated. kotlinx.serialization needs `@Serializable` on the class; Moshi and Jackson need their own adapters or module registration.
- Key mapping. Names are camelCased, so a `created_at` key becomes `createdAt`. Add `@SerialName("created_at")` or the equivalent for your library.
- Nullability. Kotlin types are non-null unless marked, and every property here arrives non-null. Add `?` to anything the server may send as `null`.
- Absent against null. In kotlinx.serialization, giving a property a default value makes its key optional in the input, while marking it nullable only permits an explicit `null`. Those are different guarantees, and no single sample can tell them apart.
- Collections are typed from the first element, and `Long` against `Double` is decided by whether the sample value had a decimal point.

> **Construct with named arguments** — Kotlin does not require named arguments, so a fifteen-property data class can be built positionally. That is where two adjacent `String` fields quietly swap and the bug survives review. Name them at every construction site that is not generated code.

For the same API on iOS, [JSON to Swift](https://convertto.tech/t/json-to-swift) emits the `Codable` equivalent, and [JSON to Dart](https://convertto.tech/t/json-to-dart) covers a Flutter client.

## How to use

1. Enter or paste your json.
2. Enter or paste your root type name.
3. Press Run, then download the result when it is ready.

## FAQ

### Does this JSON to Kotlin Data Class converter upload my files?

No, all type generation runs purely in JavaScript in your browser.

## Sources

- [RFC 8259: The JavaScript Object Notation (JSON) Data Interchange Format](https://www.rfc-editor.org/rfc/rfc8259) — IETF
- [Kotlin documentation: serialization](https://kotlinlang.org/docs/serialization.html) — JetBrains

## Related tools

- [JSON to C# Model Converter](https://convertto.tech/t/json-to-csharp): Convert JSON objects into strongly-typed C# Model definitions and data models.
- [JSON to Dart Class Converter](https://convertto.tech/t/json-to-dart): Convert JSON objects into strongly-typed Dart Class definitions and data models.
- [JSON to Go Struct Converter](https://convertto.tech/t/json-to-go): Convert JSON objects into strongly-typed Go Struct definitions and data models.
- [JSON to Java Class Converter](https://convertto.tech/t/json-to-java): Convert JSON objects into strongly-typed Java Class definitions and data models.
- [JSON to Mongoose Schema Converter](https://convertto.tech/t/json-to-mongoose): Convert JSON objects into strongly-typed Mongoose Schema definitions and data models.
- [JSON to Prisma Model Converter](https://convertto.tech/t/json-to-prisma): Convert JSON objects into strongly-typed Prisma Model definitions and data models.
- [JSON to Python Dataclass Converter](https://convertto.tech/t/json-to-python): Convert JSON objects into strongly-typed Python Dataclass definitions and data models.
- [JSON to Rust Struct Converter](https://convertto.tech/t/json-to-rust): Convert JSON objects into strongly-typed Rust Struct definitions and data models.
