JSON to Kotlin Converter
Convert JSON to Kotlin data classes online with kotlinx.serialization or Gson annotations, nullable types and List<T> — 100% in your browser.
What is the JSON to Kotlin Converter?
The ByteTools JSON to Kotlin Converter generates data classes from a sample JSON document. It emits camelCase properties with @SerialName (kotlinx.
- kotlinx.serialization, Gson or annotation-free output
- camelCase properties with @SerialName / @SerializedName mapping
- Nullable types with = null defaults for optional keys
- Nested data classes named from their JSON keys
- Int, Long and Double chosen from the actual values
- 100% private — nothing leaves your browser
How to use the JSON to Kotlin Converter
- 1
Paste a JSON sample into the input box.
- 2
Set the root class name and pick an annotation style (kotlinx.serialization, Gson or none).
- 3
Click Generate Kotlin to build the data classes.
- 4
Copy the result or download it as a .kt file.
About the JSON to Kotlin Converter
The ByteTools JSON to Kotlin Converter generates data classes from a sample JSON document. It emits camelCase properties with @SerialName (kotlinx.serialization) or @SerializedName (Gson) annotations that map back to the original keys, nullable types with default null values, List<T> for arrays and nested data classes named after their parent key.
It is made for Android and Kotlin backend developers who need models for an API response without writing them by hand. Arrays of objects are merged into a single class, keys that appear only in some elements become nullable, and you can switch between kotlinx.serialization, Gson or plain unannotated classes with one dropdown.
The generator runs 100% locally in your browser — your JSON is never uploaded or stored anywhere, so production payloads and internal schemas remain private while you work.
Frequently asked questions
How do I convert JSON to Kotlin data classes?
Paste your JSON sample, choose the annotation style your project uses and click Generate Kotlin. Each object shape becomes a data class, snake_case keys are renamed to camelCase properties, and the annotation keeps the original key for serialization.
Should I pick kotlinx.serialization or Gson?
Pick whatever your project already uses. kotlinx.serialization is the JetBrains-official, multiplatform choice and adds @Serializable to each class; Gson is common in older Android codebases. The class structure is identical either way.
How are nullable fields handled?
Any field that is null in the sample, or missing from some objects in an array, becomes a nullable type with a default of null, e.g. val nickname: String? = null. That keeps deserialization safe when the key is absent.
What happens to keys that are not valid Kotlin identifiers?
With annotations enabled the property gets a clean camelCase name and the annotation carries the original key. With annotations off, the raw key is kept and wrapped in backticks when needed so the code still compiles.
Is my JSON sent to a server?
No. The entire conversion happens in your browser with JavaScript — nothing is uploaded, logged or stored, so it is safe for confidential API responses.
Related tools
JSON to Swift Converter
Convert JSON to Swift Codable structs online. Generates camelCase properties, CodingKeys for snake_case keys and optionals — all in your browser.
JSON to Dart Converter
Convert JSON to null-safe Dart classes online, with generated fromJson and toJson methods, typed List<T> fields and nested classes — in your browser.
JSON to TypeScript
Generate TypeScript interfaces from a JSON sample online. Infers types recursively, merges array shapes and marks optional keys — 100% in your browser.
JSON Formatter
Format, beautify and minify JSON online with 2-space, 4-space or tab indentation. Sort keys alphabetically and catch syntax errors instantly — free and private.
JSON to C# Converter
Convert JSON to C# classes or records online. Infers types from a sample, adds JsonPropertyName attributes and nullable types — all in your browser.