Paste C# models built from class, record or struct and get an example JSON document following System.Text.Json and Newtonsoft.Json rules. Choose between the camelCase naming policy ASP.NET Core uses by default and property names as written; names set with [JsonPropertyName] or [JsonProperty] always win.
Use it to hand a sample to a frontend or an external partner from Web API request/response models, to fill Swagger (Swashbuckle) examples, or to prepare bodies for HttpClient integration tests.
using, namespace, constructors and methods can remain.Naming policy: camelCase (ASP.NET Core default) for standard Web API projects, or Property names as-is if you set PropertyNamingPolicy = null or rely on Newtonsoft defaults.Root type on Auto, the first type no other model references becomes the root; change it from the list if needed..http file or an xUnit request body. Your option choices are saved in the URL.public class InventoryItem
{
public Guid Id { get; set; }
public string SKU { get; set; } = "";
[JsonPropertyName("stock_qty")]
public int StockQuantity { get; set; }
public StockState State { get; set; } = StockState.InStock;
public DateTimeOffset UpdatedAt { get; set; }
public List<string> Barcodes { get; set; } = new();
[JsonIgnore]
public string WarehouseNote { get; set; } = "";
private int _version;
}
public enum StockState { InStock, LowStock, OutOfStock }{
"id": "00000000-0000-0000-0000-000000000000",
"sku": "",
"stock_qty": 0,
"state": 0,
"updatedAt": "1970-01-01T00:00:00+00:00",
"barcodes": [
""
]
}Under the camelCase policy an all-caps name like SKU becomes sku, matching System.Text.Json's JsonNamingPolicy.CamelCase, while [JsonPropertyName("stock_qty")] keeps its name regardless of policy. WarehouseNote ([JsonIgnore]) and the private field _version are left out. The enum State has no string converter, so it shows 0, the numeric value of its initializer StockState.InStock.
[JsonPropertyName], Newtonsoft [JsonProperty], and [DataMember(Name = ...)].public properties and fields are included, plus non-public members marked [JsonInclude]. static, const, [JsonIgnore] and [IgnoreDataMember] are excluded; conditional ignores such as Condition = WhenWritingNull are kept.record Customer(long Id, string Name)) and [property: JsonPropertyName(...)] targets are supported.=> ...) are included, as System.Text.Json would serialize them.= 10 included). With [JsonConverter(typeof(JsonStringEnumConverter))] (or Newtonsoft StringEnumConverter) on the enum or the property, or [JsonStringEnumMemberName] / [EnumMember(Value = ...)] on members, the name string is used instead.DateTime → 1970-01-01T00:00:00, DateTimeOffset → 1970-01-01T00:00:00+00:00, DateOnly → 1970-01-01, TimeOnly/TimeSpan → 00:00:00, Guid → all-zero GUID.int?/Nullable<T> use the inner type, List<T>/IEnumerable<T>/arrays get one element, Dictionary<int, V> uses a "0" key, and object, JsonElement and JObject become null.= 1.5, = "KRW") are used as sample values.DTOs that mix [JsonPropertyName] with default naming make Swagger UI's generated examples easy to misread. Use this output in an ISchemaFilter or an XML <example> comment so the docs and the response share the same keys.
Switch the Naming policy back and forth on the same model to preview how key casing changes after the migration.
When client and server keep separate copies of a model, generate JSON from each side and compare them to spot key-name mismatches quickly.
JsonStringEnumConverter registered globally with AddJsonOptions in Program.cs is invisible in the model code, so enums still come out as numbers. To see names, add [JsonConverter(typeof(JsonStringEnumConverter))] to the enum declaration before pasting.string? get a typed sample, not null.[JsonConverter] attributes other than the enum string converter, DefaultIgnoreCondition in JsonSerializerOptions, and snake_case policies (JsonNamingPolicy.SnakeCaseLower) are not applied.[JsonPolymorphic]/[JsonDerivedType] is not supported; only the declared base type is generated.Naming policy option?ASP.NET Core Web API uses JsonSerializerDefaults.Web, which is camelCase. A console app calling JsonSerializer.Serialize without options, or default Newtonsoft.Json settings, keeps property names, so choose Property names as-is there.
public string FullName => ... appear?Both System.Text.Json and Newtonsoft.Json serialize public properties with a getter, so computed properties end up in responses too. Add [JsonIgnore] if you don't want them exported.
[JsonPropertyName] on a record's positional parameter doesn't rename the key at runtime.Without a target, the compiler applies the attribute only to the constructor parameter. This tool recognizes both forms, but to rename the serialized property reliably write [property: JsonPropertyName("...")].
Z on DateTime values?A DateTime with DateTimeKind.Unspecified serializes without an offset. If you need an explicit UTC offset, DateTimeOffset produces the +00:00 form.