Back to all tools
JSON to .NET DTO
Paste JSON and instantly generate C# Data Transfer Object classes or records for .NET Core.
JSON InputValid
Generated C# Code
C# / .NET Core20 properties
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace MyApp.Dto;
public class Root
{
[JsonPropertyName("id")]
public int Id { get; set; }
[JsonPropertyName("firstName")]
public string FirstName { get; set; }
[JsonPropertyName("lastName")]
public string LastName { get; set; }
[JsonPropertyName("email")]
public string Email { get; set; }
[JsonPropertyName("isActive")]
public bool IsActive { get; set; }
[JsonPropertyName("balance")]
public decimal Balance { get; set; }
[JsonPropertyName("createdAt")]
public DateTime CreatedAt { get; set; }
[JsonPropertyName("tags")]
public List<string> Tags { get; set; }
[JsonPropertyName("address")]
public Address Address { get; set; }
[JsonPropertyName("orders")]
public List<Order> Orders { get; set; }
}
public class Address
{
[JsonPropertyName("street")]
public string Street { get; set; }
[JsonPropertyName("city")]
public string City { get; set; }
[JsonPropertyName("zipCode")]
public string ZipCode { get; set; }
[JsonPropertyName("country")]
public string Country { get; set; }
}
public class Order
{
[JsonPropertyName("orderId")]
public int OrderId { get; set; }
[JsonPropertyName("total")]
public decimal Total { get; set; }
[JsonPropertyName("status")]
public string Status { get; set; }
}About JSON to .NET DTO
JSON to .NET DTO analyzes a JSON object and generates C# Data Transfer Object (DTO) class definitions with proper types, property names, and optional JsonPropertyName attributes. It saves significant time when building .NET APIs that consume or produce JSON. Paste JSON and copy ready-to-use C# code.
- Generates C# class from JSON
- Proper type inference for all values
- Optional JsonPropertyName attributes
- Handles nested objects and arrays