Include different records
Place several objects of the same response shape in a top-level array. A key appearing only later becomes nullable, while nested arrays are inspected across their elements.
Type generation
Try the two-record example, then choose a target language and a root type name.
The JSON is parsed and generated in this browser; no sample is uploaded or stored.
2 declarations · 2 nullable types
JSON to model turns a representative API response into a starting type. One array can show both records with different keys, so a field found only in the second record is not lost.
Use the generated declaration as a draft. A single response cannot establish business rules, future fields, exact decimal behavior or your project's serializer configuration.
JSON to model reads all objects in the top-level array. Fields missing from some records remain in the generated type as nullable rather than disappearing because the first record lacked them.
The same local JSON becomes Rust structs, C# classes, Dart classes, PHP classes or Scala case classes. Each download carries the selected language's file extension.
Place several objects of the same response shape in a top-level array. A key appearing only later becomes nullable, while nested arrays are inspected across their elements.
Rust emits Serde fields; C# uses System.Text.Json attributes; Dart includes fromJson and toJson; PHP and Scala emit model declarations that still need project-side hydration or codecs.
Auto-generation waits 350 ms after edits. Turn it off to reveal Generate model or press Ctrl/Cmd+Enter. Any input or option change disables copy and download until the new run succeeds.
A JSON to Rust struct uses Serde rename attributes, Option and Vec. C# retains original keys with JsonPropertyName and uses nullable properties where the sample shows gaps.
The Dart model generator emits typed fields plus fromJson and toJson methods for nested objects and lists. Test generated code with your actual Flutter or Dart runtime.
PHP 8 receives typed properties and array item docblocks. A Scala case class receives Option and List where evidence supports them; a codec is still a separate project choice.
This JSON to class generator reads number tokens before JavaScript can round them. Out-of-range or decimal values fall back to broad target-language types instead of a falsely precise integer.
JSON to model supports Rust, C#, Dart, PHP and Scala on this page. The selector lists only these implemented outputs; each has a matching source-file extension.
All objects in the top-level array are examined. If a key is missing in some records or its value is null, the field becomes nullable where the target language supports that. A null-only field remains an unknown type.
Yes. Nested objects become named models, and arrays infer an item type from all visible elements. Mixed item kinds fall back to broad types that you should refine against more examples.
Yes. Root is the default. Enter an ASCII name starting with a capital letter; changing it regenerates the declarations and the downloaded filename.
Dart includes fromJson and toJson. Rust has Serde derives and C# has System.Text.Json key attributes. PHP and Scala outputs are declarations only, so your application supplies hydration or a codec.
Found a shape we should handle?
Run JSON to model with several realistic records, inspect the nullable fields and names, then download the current language's source file for project-side testing.