JSON to code

Typed classes for C#, TypeScript, Dart, Kotlin, Java, Python or Go.

About & FAQ ↓
Sample JSON
Waiting for input.
Generated code

Generated from one sample, so treat optionality and numeric widths as a first draft.

Reference
JSON to code

About the JSON to code generator

Turning an API response into model classes by hand is busywork. Paste the payload and get types for your language, with the serialisation attributes that language expects. Array elements are merged before generating, so a key that appears in only some elements becomes an optional field rather than being lost — the mistake most generators make when they read only the first element.

01

Seven languages

C#, TypeScript, Dart, Kotlin, Java, Python and Go, each with idiomatic naming.

02

Serialisation attributes

JsonPropertyName, SerialName, JsonProperty, json tags — the annotation your stack expects.

03

Optionality preserved

A key missing from some array elements becomes an optional or nullable field, not a lost one.

04

Nested types named

Nested objects become their own classes, singularised from the property that held them.

How to use it

  1. Paste a representative payload — include elements with optional fields present and absent.
  2. Pick the language, name the root type, and choose whether to emit serialisation annotations and nullable optionals.
  3. Copy the code, or download it as a file named after the root type.

Questions

Which languages are supported?

C#, TypeScript, Dart, Kotlin, Java, Python and Go. C# emits [JsonPropertyName], Kotlin @SerialName, Java @JsonProperty, Go json tags with omitempty, and Dart gets fromJson/toJson methods.

How are optional fields handled?

A key missing from any element of an array is treated as optional: nullable in C# and Kotlin, `?` in TypeScript, Optional[...] with a default in Python, a pointer in Go.

What happens with mixed types?

integer and floating-point values in the same position widen to the language's floating type. Genuinely mixed types (a string and an object, say) fall back to the language's open type — object, unknown, dynamic or interface{}.