Class or record
Classes with { get; set; } properties, or positional records with property attributes.
Create C# classes or records with System.Text.Json attributes from example JSON.
Generate C# classes or records from JSON with [JsonPropertyName] attributes, nullable reference types and List<T>. Ready for System.Text.Json.
{"id":7,"user_name":"aarav","rating":4.5}using System.Text.Json.Serialization;
public class User
{
[JsonPropertyName("id")]
public int Id { get; set; }
[JsonPropertyName("user_name")]
public string UserName { get; set; } = string.Empty;
[JsonPropertyName("rating")]
public double Rating { get; set; }
}Tip: Paste several array items so properties that are sometimes missing are detected as nullable.
Classes with { get; set; } properties, or positional records with property attributes.
[JsonPropertyName] keeps the original JSON key while properties use PascalCase.
Optional and null fields become string?, int? and so on; required strings default to string.Empty.
long for large numbers, double, bool, DateTimeOffset for ISO timestamps and List<T> for arrays.
System.Text.Json (.NET Core 3.0 and later). For Newtonsoft.Json, replace [JsonPropertyName] with [JsonProperty].
They were null or missing in your sample, so they are nullable.
The output assumes <Nullable>enable</Nullable>, which is the default for new .NET projects.
Yes, generation happens in your browser.