JSON to C#
Convert JSON objects into C# classes with properties, nested models, collection types, nullable options, and JSON property-name attributes.
Runs locally in your browser
JSON Input
C# Output
using System.Collections.Generic;
using System.Text.Json.Serialization;
#nullable enable
// Generated from JSON.
// Review inferred types before using these models.
public class Profile
{
[JsonPropertyName("country")]
public string? Country { get; set; }
[JsonPropertyName("timezone")]
public object? Timezone { get; set; }
}
public class ProjectsItem
{
[JsonPropertyName("name")]
public string? Name { get; set; }
[JsonPropertyName("stars")]
public int Stars { get; set; }
[JsonPropertyName("active")]
public bool? Active { get; set; }
}
public class GeneratedModel
{
[JsonPropertyName("id")]
public int Id { get; set; }
[JsonPropertyName("name")]
public string? Name { get; set; }
[JsonPropertyName("email")]
public string? Email { get; set; }
[JsonPropertyName("isActive")]
public bool IsActive { get; set; }
[JsonPropertyName("roles")]
public List<string>? Roles { get; set; }
[JsonPropertyName("profile")]
public Profile? Profile { get; set; }
[JsonPropertyName("projects")]
public List<ProjectsItem>? Projects { get; set; }
}
Generation notes
- • Nested objects become separate C# classes.
- • Object arrays merge fields from all objects.
- • Missing properties are treated as optional.
- • Nullable value types can represent JSON null values.
- • JsonPropertyName preserves original JSON property names.
- • Review mixed-type arrays before using the generated model.
How to use JSON to C#
- 1Paste a valid JSON object or array.
- 2Set the root class name and nullable options.
- 3Copy or download your generated C# classes.