JSON to C#
- System.Text.Json
- Nullable
- Instant
Classes with System.Text.Json attributes and nullable annotations.
Paste input on the left to see c#.
Everything runs in your browser — nothing is uploaded.
About c#
Generating C# classes from JSON produces auto-properties with System.Text.Json JsonPropertyName attributes preserving the original keys. JSONic annotates properties that can be absent as nullable, so the classes compile cleanly under nullable reference types. Swap the attribute for JsonProperty to use Newtonsoft instead.
Paste JSON and get C# classes ready for System.Text.Json. Property names become PascalCase with a JsonPropertyName attribute preserving the original key, and keys absent from some array elements are annotated nullable so they work under nullable reference types rather than producing warnings.
Questions
Does this target System.Text.Json or Newtonsoft?
System.Text.Json, the built-in serializer since .NET Core 3.0. For Newtonsoft.Json, swap JsonPropertyName for JsonProperty — the class structure is identical.
Will it work with nullable reference types enabled?
Yes. Properties that can be absent are annotated with ?, so the compiler does not warn about uninitialised non-nullable members.
Are properties or fields generated?
Auto-properties with get and set, which is what System.Text.Json binds to by default. Fields require explicit configuration to be serialized at all.