Omnikit
DevFilesMoneyAll tools
Ctrl K
Dev toolsFile toolsMoney calculatorsAll tools
HomeDeveloper toolsJSON to Kotlin Data Class ConverterJSON to Kotlin for Gson

JSON to Kotlin for Gson

dev

Paste JSON and get Kotlin data classes with @SerializedName for Gson

Runs in your browser. Nothing you type is sent anywhere. Checked against sources on 16 Oct 2026.

Android projects that parse JSON with Gson need a Kotlin data class for every object, with @SerializedName wherever the property name differs from the key. Paste a response and get those classes: camelCase properties, the original key in each annotation, Int, Long or Double chosen per field, and nullable types wherever the sample shows null or some items leave a key out.

Next:
  • JSON to Java Class Converter Turn a JSON sample into Java POJOs, records or Lombok classes annotated for Jackson
  • JSON Formatter & Validator Format, validate, minify and sort JSON with exact error positions

How to use JSON to Kotlin for Gson

1

Paste or type your input.

2

Choose the options you need.

3

Press Ctrl+Enter, then copy or download.

How JSON to Kotlin for Gson works

Kotlin reads JSON into data classes, and each object needs a class whose properties have the right types, the right nullability and a way back to their keys. This converter writes those classes from a sample, so a long API response becomes Kotlin in one paste.

JSON value Kotlin type
"text" String
true / false Boolean
42 (whole numbers only) Int, or Long beyond 32 bits
4.5 (any decimal seen) Double
null, and also a type String?, Int?
only null, or mixed kinds JsonElement? or Any?
[ ... ] List<...>
{ } empty JsonObject or Map<String, Any?>
{ ... } a data class of its own

Names. Properties are lowerCamelCase. Where that changes the key, as user_name to userName, the property carries @SerialName, @SerializedName or @Json(name = ...), depending on the library. Keywords such as class are written in backticks. Annotation strings escape the dollar sign, since Kotlin would read it as a template.

The rest of the article, and all 6 questions about JSON to Kotlin Data Class Converter, are on the JSON to Kotlin Data Class Converter page.

Frequently asked questions

How do I convert JSON to a Kotlin data class?

Paste a JSON sample into the converter and the data classes appear beside it, one per object. With kotlinx.serialization, add the plugin and decode with Json.decodeFromString<Root>(text); with Gson use Gson().fromJson(text, Root::class.java); with Moshi build an adapter for Root.

Which library should I choose?

kotlinx.serialization is Kotlin's own, works on every Kotlin platform and checks types at compile time. Moshi with codegen suits Android projects that already use Retrofit and Okio. Gson is the oldest and needs no setup, but it ignores Kotlin's null safety and default values when it creates objects.

How are keys like user_name or class handled?

Properties are lowerCamelCase, so user_name becomes userName with @SerialName, @SerializedName or @Json(name = ...) keeping the original key. A key that is a Kotlin keyword, such as class or object, is written in backticks, which keeps the key as the property's real name.

How are numbers typed in Kotlin?

Whole numbers become Int, or Long when a value is beyond 2,147,483,647, and a field becomes Double as soon as any sample value has a decimal part. Values of different kinds become JsonElement? with kotlinx.serialization, or Any? with Gson and Moshi.

Sources

  • Kotlin documentation, keywords and operatorsHard keywords that need backticks as names
  • Kotlin documentation, coding conventions: naming rulesUpperCamelCase classes, lowerCamelCase properties
  • kotlinx.serialization guide, basic serialization@SerialName, optional properties need defaults, unknown keys are errors
  • Moshi README, Kotlin codegen@JsonClass(generateAdapter = true) and @Json(name = ...)

Last verified 16 October 2026.

Rates and rules change; check the source before you rely on a figure.

Still stuck? Ask about JSON to Kotlin Data Class Converter and anybody who knows can answer. No account needed.

More ways to use JSON to Kotlin Data Class Converter

  • JSON to Kotlin Data Class ConverterTurn a JSON sample into Kotlin data classes for kotlinx.serialization, Gson or Moshi

Same job, other tools: Image to Base64 – Get a data URI for any image, ready for CSS or HTML · TSV to JSON – Convert tab-separated values, such as a paste from Excel, into JSON · JSON to YAML – Turn JSON into clean, readable YAML for configs · Query String Parser – Split a URL query string into a table of decoded parameters.

Related tools

All developer tools
Base64 Encode & DecodeText and files to Base64 and back, with URL-safe mode and image previewUnix Timestamp ConverterUnix timestamps to dates and dates to timestamps, in any time zoneJSON to TypeScriptGenerate TypeScript interfaces or types from a JSON sampleCSV to JSONConvert CSV to JSON and JSON to CSV, with a table previewYAML to JSONConvert YAML to JSON and JSON to YAML, with anchors resolvedURL Encoder / DecoderPercent-encode or decode text and URLs, and see every part of a linkColor ConverterHEX, RGB, HSL, HWB, OKLCH and CMYK in both directions, with a contrast checkNumber Base ConverterBinary, octal, decimal, hex and any base to 36, exact at any size, with two's complement
Was this tool helpful?
Omnikit

Small jobs, done in your browser. Free, fast and private. Files are never uploaded.

Files

  • Compress Image
  • Image to PDF
  • Merge PDF
  • Compress PDF
  • PDF to Word
  • Word to PDF

Dev

  • JSON Formatter & Validator
  • Base64 Encode & Decode
  • JWT Decoder, Verifier & Encoder
  • Password Generator
  • UUID Generator
  • Unix Timestamp Converter

Money

  • SIP Calculator
  • EMI Calculator
  • GST Calculator
  • FD Calculator
  • PPF Calculator
  • Lumpsum Calculator
GuidesQuestionsAboutHow we checkLaw library (beta)PrivacyTermsDisclosureContactMore: Exam practice (UGC NET Paper 1)Runs in your browser. Nothing is uploaded. © 2026 Omnikit (theomnikit.com)