{"generatedAt":"2026-07-19T03:01:59.444Z","tool":{"id":"json-to-kotlin","name":"JSON to Kotlin Data Class","description":"Convert JSON to Kotlin data classes with @Serializable annotations — supports kotlinx.serialization, Gson, and Moshi","category":"converter","icon":"Kt","keywords":["json to kotlin","kotlin data class generator","kotlin serialization","json converter kotlin"],"isNew":true,"remoteCallable":true,"remoteMode":"dedicated_api","riskClass":"L","maxInputBytes":131072,"timeoutMs":2000,"supportsStreaming":false,"url":"/json-to-kotlin/","tags":["converter"],"faqs":[{"question":"What is a Kotlin data class?","answer":"A Kotlin data class is a class that holds data with automatic equals(), hashCode(), toString(), and copy() methods. They're ideal for modeling API responses, database entities, and immutable data structures. Use the 'data class' keyword to define them."},{"question":"What's the difference between the serialization libraries?","answer":"kotlinx.serialization is the official Kotlin multiplatform library with minimal reflection. Gson is Google's popular JSON serializer. Moshi is Square's modern alternative with better error messages. Each has different import statements and annotations, but all are widely supported."},{"question":"What does @Serializable do?","answer":"@Serializable is an annotation that marks a class as serializable for JSON conversion. With kotlinx.serialization, the compiler generates serialize/deserialize code at compile time. Other libraries use different annotations (@Serializable for Moshi requires @Json field annotations)."},{"question":"How do nullable fields work?","answer":"If you enable 'Nullable fields', all properties become nullable (String? instead of String). This means they can hold null values. This is useful when API responses have optional fields or you need to handle missing data gracefully."},{"question":"Can I use the generated code directly?","answer":"Yes. Copy the generated Kotlin code into your Android or server project. Add the appropriate serialization library to your build.gradle, then use the generated data classes to parse JSON with MyClass.serializer().deserialize(jsonString) or your library's equivalent method."}],"howTo":[{"title":"Paste your JSON data","description":"Input a JSON object or array in the left panel. The tool parses the structure and infers Kotlin types: strings become String, integers become Int or Long, decimals become Double, booleans become Boolean, and null becomes Any?."},{"title":"Configure data class options","description":"Set the root class name (default: Root). Toggle nullable types for optional fields. Choose between data classes and regular classes. Enable @SerializedName annotations for custom JSON key mapping."},{"title":"Review generated Kotlin code","description":"The right panel shows idiomatic Kotlin data classes with proper type annotations. Nested JSON objects become separate named data classes. Copy the output directly into your Kotlin project."}],"agentContract":{"toolId":"json-to-kotlin","contractVersion":"2.0.0","remote_callable":true,"remote_mode":"dedicated_api","risk_class":"L","max_input_bytes":131072,"timeout_ms":2000,"supports_streaming":false,"preferred_surface":"dedicated_api","dedicated_api":{"baseUrl":"https://aidevhub.io/api/json-to-kotlin/","openapiUrl":"https://aidevhub.io/api/openapi.yaml","endpoints":[{"method":"GET","path":"/api/json-to-kotlin/","summary":"GET json-to-kotlin"},{"method":"POST","path":"/api/json-to-kotlin/","summary":"POST json-to-kotlin"}],"riskClass":"L","inputMaxBytes":131072,"timeoutMs":2000},"runtime":{"endpoint":"/api/tools/run/","methods":["GET","POST"],"queryParams":[{"name":"toolId","required":true,"description":"Tool identifier"},{"name":"a","required":true,"description":"Primary input"}],"postBodyShape":{"toolId":"string","input":"{ a, b?, c?, mode? }"},"exampleGet":"https://aidevhub.io/api/tools/run/?toolId=json-to-kotlin&a=...","policy":{"riskClass":"L","limit":60,"burst":20,"windowSec":60,"inputMaxBytes":131072,"timeoutMs":2000,"cacheTtlSec":0,"networkEnabled":false,"supportsStreaming":false}}},"relatedTools":[{"id":"tailwind-converter","name":"CSS to Tailwind Converter","url":"/tailwind-converter/","category":"converter"},{"id":"html-to-jsx","name":"HTML to JSX Converter","url":"/html-to-jsx/","category":"converter"},{"id":"color-converter","name":"Color Converter","url":"/color-converter/","category":"converter"},{"id":"json-to-go","name":"JSON to Go Struct","url":"/json-to-go/","category":"converter"},{"id":"json-to-python","name":"JSON to Python Dataclass","url":"/json-to-python/","category":"converter"},{"id":"json-to-typescript","name":"JSON to TypeScript Converter","url":"/json-to-typescript/","category":"converter"}]}}