🔷

JSON to C#

Generate C# classes from sample JSON with nested types, List generics, nullable reference types and JsonProperty attributes for .NET API clients and models.

json-to-go.input
json-to-go.output
using System;
using System.Collections.Generic;
using Newtonsoft.Json;

public class Profile
{
        [JsonProperty("age")]
        public int Age { get; set; }
        [JsonProperty("city")]
        public string? City { get; set; }
}

public class RootObject
{
        [JsonProperty("id")]
        public int Id { get; set; }
        [JsonProperty("name")]
        public string? Name { get; set; }
        [JsonProperty("active")]
        public bool Active { get; set; }
        [JsonProperty("score")]
        public double Score { get; set; }
        [JsonProperty("tags")]
        public List<string>? Tags { get; set; }
        [JsonProperty("profile")]
        public Profile Profile { get; set; }
}

About JSON to C#

Consuming JSON APIs in .NET means writing many C# classes by hand. This tool parses your sample JSON locally and generates complete C# classes: field names become PascalCase, nested objects become separate classes, arrays infer to List<T>, with nullable reference types and Newtonsoft.Json / System.Text.Json JsonProperty attributes. Nothing is uploaded.

How to Use

  1. Open the JSON to C# tool page
  2. Enter or paste your data into the input area
  3. View the real-time results and use the copy button to get the output

Use Cases

  • Consume REST APIs — Convert API JSON to C# classes for HttpClient/RestSharp deserialization.
  • EF Core entities — Generate entity classes from database JSON samples for Entity Framework Core.
  • Unity config modeling — Create type-safe C# models for Unity game configuration JSON.
  • Azure Function inputs — Quickly generate input model classes for Azure Function HTTP Triggers.

FAQ

What is the difference between Newtonsoft and System.Text.Json?

Newtonsoft.Json uses [JsonProperty]; System.Text.Json uses [JsonPropertyName]. Choose based on your project dependency.

How are null values handled?

null infers to object?. Use a non-null sample for more precise types.

What are nullable reference types?

A C# 8+ feature. When enabled, reference type fields like string are marked nullable (string?) and the compiler checks for nulls.

How are nested objects handled?

Each nested object becomes its own class - clean and reusable.

Comments

No comments yet. Be the first!

💬 Comments are stored locally in your browser. Configure Giscus for cloud-based comments.