Paste an existing Kotlin data class and see what it looks like once serialized, as a sample JSON document. Nested classes, List/Map properties and enums are followed and filled in, and renaming annotations such as @SerialName are applied to the keys.
Reach for it when a server and an app share models and you need to confirm which JSON a class really sends and receives, or when an API doc or mock server needs a request body sample.
import/package lines and member functions can stay in; they are skipped.Root type on Auto in most cases: the first class not referenced by another class becomes the root. You can also pick a specific class from the list.Money class from another file) come out as null, and their names are listed next to the options. Paste those classes too and they get filled in.@Serializable
data class Article(
val id: Long,
val title: String,
@SerialName("author_name") val authorName: String,
val status: PostStatus = PostStatus.DRAFT,
val tags: List<String> = emptyList(),
val publishedAt: Instant? = null,
@Transient val cachedHtml: String = "",
)
@Serializable
enum class PostStatus {
@SerialName("draft") DRAFT,
@SerialName("published") PUBLISHED,
}{
"id": 0,
"title": "",
"author_name": "",
"status": "draft",
"tags": [
""
],
"publishedAt": "1970-01-01T00:00:00Z"
}authorName is emitted as author_name because of @SerialName, and the default PostStatus.DRAFT resolves to "draft" through the enum entry's own @SerialName. cachedHtml is marked @Transient, so it is dropped. A nullable property defaulting to null, like publishedAt, still gets a typed sample (Instant → ISO timestamp) rather than null.
@SerialName, Jackson @JsonProperty, Gson @SerializedName and Moshi @Json(name = ...).@Transient or @JsonIgnore, private properties, delegated ones like by lazy, getter-only computed properties, const values and companion object members.Status.PAID becomes that entry's JSON value.@SerialName.LocalDate → 1970-01-01, LocalDateTime → 1970-01-01T00:00:00, Instant/OffsetDateTime → ISO string ending in Z, Duration → PT0S; UUID gets a well-formed value.List, Set and Array get one sample element; a map with a numeric key type such as Map<Int, V> uses "0" as the key.null or an empty array instead of expanding forever.Paste a response DTO and you have the JSON skeleton for an OpenAPI example or a README. Fields renamed through @SerialName appear under the same name the serializer will actually write.
Build the body for MockWebServer or a local JSON fixture from the very model your Retrofit interface returns. Swap the placeholder values ("", 0) for realistic data and the structure still matches the model.
Show the server team exactly what the app sends, or compare a received spec against your Kotlin model to catch key-name mismatches before they become runtime errors.
"", 0, false), not realistic data; replace them before publishing docs.String?) also get a typed sample rather than null, so mark separately which fields may actually be null.@JsonNaming or kotlinx JsonNamingStrategy are not applied; unannotated properties keep their Kotlin name as the key.type discriminator) and custom KSerializers are not reflected.emptyList() or listOf(...), are not evaluated; the value comes from the declared type instead.@Transient property is missing from the output. Is that expected?Yes. kotlinx.serialization @Transient and Jackson @JsonIgnore keep a field out of serialization, so the sample omits it too. A private val declared in the class body is left out for the same reason.
The class syntax is the same, so they parse fine. Renames from Gson @SerializedName("...") and Moshi @Json(name = "...") are recognized.
= null, so why does the field have a value?The goal is to show each field's shape, so a null default is ignored and a typed sample is used. That way you can see, for example, which string format an Instant? travels as.
Paste them one after another into the same input. Any type still missing is named next to the options, which tells you what else to add.