JSON Repair
Fix broken JSON: trailing commas, single quotes, unquoted keys and comments.
Generate C# classes with System.Text.Json attributes from a JSON sample.
Leave them off if your serialiser is configured with a camelCase naming policy and the mapping is implicit.
The JSON to C# Class converter writes model classes with PascalCase properties, JsonPropertyName attributes carrying the original keys, List<T> collections and nullable value types wherever a field can be absent.
Paste a payload and get the model classes: PascalCase properties with getters and setters, a JsonPropertyName attribute carrying the original key, List<T> for arrays and a nested class for every nested object.
Optional fields are declared as nullable value types — long?, double?, bool?, DateTime? — so an absent key deserialises as null rather than silently becoming zero. Values that look like timestamps are typed as DateTime, numbers as long or double depending on whether a decimal point appears anywhere in the sample, and you can drop the attributes entirely if your serialiser is configured with a camelCase naming policy instead.
JsonPropertyName preserves the original JSON key, so PascalCase properties bind correctly however the API names its fields.
long?, double? and bool? are used where a key can be missing, so an absent number does not silently deserialise as zero.
Values in ISO 8601 form are typed as DateTime rather than string, which is what you actually want to work with.
Drop them entirely when your serialiser is configured with a camelCase naming policy and the mapping is implicit.
Swapping JsonPropertyName for JsonProperty and the using directive is all it takes if your project is on Newtonsoft.Json.
An array of records detects optional fields better than a single object.
Nested classes are named from the keys that contain them.
Keep JsonPropertyName for explicit mapping, or drop it if you use a naming policy.
Paste into a .cs file — the using directives are included.
The output targets System.Text.Json, the built-in serialiser since .NET Core 3.0. For Newtonsoft.Json, swap JsonPropertyName for JsonProperty and the using directive for Newtonsoft.Json — nothing else changes.
Because JSON numbers routinely exceed the 32-bit range — timestamps in milliseconds and database identifiers both do. Narrow to int by hand where you know the range is safe.
Because the field is missing from some records or appears as null. Without the question mark, a missing number would deserialise as 0, which is indistinguishable from a real zero.
Not here — classes with settable properties are what System.Text.Json binds to without extra configuration. Converting the output to a positional record afterwards is a mechanical change.
What people who use the JSON to C# Class think of it. Reviews come from visitors and are posted as written.
No ratings yet
Yours would be the first.
0 reviews
Newest first
No reviews yet
Be the first to rate the JSON to C# Class. It takes half a minute and no account.
Write the first reviewFix broken JSON: trailing commas, single quotes, unquoted keys and comments.
Compare two JSON documents structurally and see exactly which paths changed.
Re-indent HTML without breaking whitespace-sensitive elements.
Draw a grid layout and get the CSS, including named template areas.
Generate ULIDs — sortable by creation time and case-insensitive.
Generate Java POJOs or records with Jackson annotations from JSON.
Compare two semantic versions and test them against a range.
See a float’s sign, exponent, mantissa and its exact decimal value.