JSON to C# Class Generator

What is JSON?

JSON (JavaScript Object Notation) is a lightweight data-interchange format used by web applications, REST APIs, mobile apps, and cloud services. It is easy for humans to read and write while remaining simple for machines to parse and generate.

JSON stores data using key-value pairs and supports objects, arrays, strings, numbers, booleans, and null values.

Conversion Settings

Property Settings

  • Convert property names to PascalCase naming convention

Attributes/Decorators

  • Add Newtonsoft.Json JsonProperty attributes to properties
  • Add NullValueHandling.Ignore to JsonProperty attributes
  • Use .NET Core JsonPropertyName attributes instead of JsonProperty

C# Classes



                    

Step-by-Step Guide

This is a free json to c# converter which converts the json objects into a class in c#.

  1. Copy the JSON object inside the first code editor.
    Make sure that the JSON string is well formatted. The JSON object should be wrapped with curly braces and should not be escaped by backslashes.

    Example JSON:
    {
        "application": {
        "id": 101,
        "name": "NiceOneCode",
        "version": "2.5.1",
        "isActive": true,
        "rating": 4.8,
        "licenseKey": "7c6f5c91-9f7a-4f5d-8d92-c5f8f4f8b123",
        "lastUpdated": "2026-06-18T10:30:45.123Z",
        "settings": {
            "theme": "Dark",
            "enableNotifications": true,
            "maxUsers": 500,
            "allowedDomains": [
            "niceonecode.com",
            "api.niceonecode.com"
            ]
        },
        "owner": {
            "userId": 1,
            "userName": "Rahul",
            "email": "admin@niceonecode.com",
            "profile": {
            "firstName": "Rahul",
            "lastName": "Maurya",
            "phone": null,
            "country": "India"
            }
        },
        "projects": [
            {
            "projectId": 1001,
            "projectName": "JSON To C# Converter",
            "createdDate": "2026-01-15",
            "tags": [
                "json",
                "csharp",
                ".net"
            ],
            "statistics": {
                "views": 25478,
                "downloads": 1240,
                "conversionRate": 12.54
            }
            },
            {
            "projectId": 1002,
            "projectName": "PDF To CSV Converter",
            "createdDate": "2026-02-10",
            "tags": [
                "pdf",
                "csv"
            ],
            "statistics": {
                "views": 17892,
                "downloads": 830,
                "conversionRate": 8.92
            },
            "extraFieldOnlyInSecondObject": "Test Value"
            }
        ],
        "supportedLanguages": [
            {
            "code": "en",
            "name": "English"
            },
            {
            "code": "hi",
            "name": "Hindi"
            }
        ],
        "metadata": {
            "server": "prod-east-01",
            "environment": "Production",
            "features": {
            "betaTools": false,
            "experimentalUI": true
            }
        },
        "emptyArray": [],
        "nullObject": null
        }
    }
  2. Click Convert button in order to start generating C# classes.
    Click the convert button and wait a few seconds until your C# classes appear.
  3. Copy the returned C# classes from the second part.
    When you copy the returned classes in the directory of your solution, you can deserialize your JSON response using the 'RootObject' class using any deserializer like Newtonsoft.
  4. This is the response you'll get from the JSON request we made earlier:
    
    // Deserialize with:
    //RootObject data = JsonConvert.DeserializeObject<RootObject>(json);
    public class RootObject
    {
        [JsonPropertyName("application")]
        public Application Application { get; set; }
    }
    public class Settings
    {
        [JsonPropertyName("theme")]
        public string Theme { get; set; }
        [JsonPropertyName("enableNotifications")]
        public bool EnableNotifications { get; set; }
        [JsonPropertyName("maxUsers")]
        public int MaxUsers { get; set; }
        [JsonPropertyName("allowedDomains")]
        public string[] AllowedDomains { get; set; }
    }
    
    public class Profile
    {
        [JsonPropertyName("firstName")]
        public string FirstName { get; set; }
        [JsonPropertyName("lastName")]
        public string LastName { get; set; }
        [JsonPropertyName("phone")]
        public object? Phone { get; set; }
        [JsonPropertyName("country")]
        public string Country { get; set; }
    }
    
    public class Owner
    {
        [JsonPropertyName("userId")]
        public int UserId { get; set; }
        [JsonPropertyName("userName")]
        public string UserName { get; set; }
        [JsonPropertyName("email")]
        public string Email { get; set; }
        [JsonPropertyName("profile")]
        public Profile Profile { get; set; }
    }
    
    public class Statistics
    {
        [JsonPropertyName("views")]
        public int Views { get; set; }
        [JsonPropertyName("downloads")]
        public int Downloads { get; set; }
        [JsonPropertyName("conversionRate")]
        public float ConversionRate { get; set; }
    }
    
    public class Project
    {
        [JsonPropertyName("projectId")]
        public int ProjectId { get; set; }
        [JsonPropertyName("projectName")]
        public string ProjectName { get; set; }
        [JsonPropertyName("createdDate")]
        public DateOnly CreatedDate { get; set; }
        [JsonPropertyName("tags")]
        public string[] Tags { get; set; }
        [JsonPropertyName("statistics")]
        public Statistics Statistics { get; set; }
        [JsonPropertyName("extraFieldOnlyInSecondObject")]
        public string ExtraFieldOnlyInSecondObject { get; set; }
    }
    
    public class SupportedLanguage
    {
        [JsonPropertyName("code")]
        public string Code { get; set; }
        [JsonPropertyName("name")]
        public string Name { get; set; }
    }
    
    public class Features
    {
        [JsonPropertyName("betaTools")]
        public bool BetaTools { get; set; }
        [JsonPropertyName("experimentalUI")]
        public bool ExperimentalUI { get; set; }
    }
    
    public class Metadata
    {
        [JsonPropertyName("server")]
        public string Server { get; set; }
        [JsonPropertyName("environment")]
        public string Environment { get; set; }
        [JsonPropertyName("features")]
        public Features Features { get; set; }
    }
    
    public class Application
    {
        [JsonPropertyName("id")]
        public int Id { get; set; }
        [JsonPropertyName("name")]
        public string Name { get; set; }
        [JsonPropertyName("version")]
        public string Version { get; set; }
        [JsonPropertyName("isActive")]
        public bool IsActive { get; set; }
        [JsonPropertyName("rating")]
        public float Rating { get; set; }
        [JsonPropertyName("licenseKey")]
        public Guid LicenseKey { get; set; }
        [JsonPropertyName("lastUpdated")]
        public DateTime LastUpdated { get; set; }
        [JsonPropertyName("settings")]
        public Settings Settings { get; set; }
        [JsonPropertyName("owner")]
        public Owner Owner { get; set; }
        [JsonPropertyName("projects")]
        public List<Project> Projects { get; set; }
        [JsonPropertyName("supportedLanguages")]
        public List<SupportedLanguage> SupportedLanguages { get; set; }
        [JsonPropertyName("metadata")]
        public Metadata Metadata { get; set; }
        [JsonPropertyName("emptyArray")]
        public List<object> EmptyArray { get; set; }
        [JsonPropertyName("nullObject")]
        public object? NullObject { get; set; }
    }
    
  5. How to Save input/output in "Json to C# Classes" converter?
    It's very easy to save input/output, just press "Save" button and it will be save and redirected to unique url.
    Save JSON to Classes
  6. How to Share saved input/output in "Json to C# Classes" converter?
    It's very easy to share saved input/output, just press "Share" button, a popup window will be opened. Press "Copy" and current url will be copied to clipboard. Share JSON to Classes Share Window

Features of JSON to C# Class Generator

Our free JSON to C# converter helps .NET developers quickly generate strongly typed C# classes from JSON data. Whether you are working with ASP.NET Core Web APIs, .NET applications, microservices, or desktop software, this tool eliminates manual model creation and speeds up development.

  • Convert JSON to C# classes instantly.
  • Generate strongly typed POCO models.
  • Support for nested JSON objects.
  • Generate classes for JSON arrays and collections.
  • Automatically detect property data types.
  • Generate PascalCase property names.
  • Support Newtonsoft.Json JsonProperty attributes.
  • Support System.Text.Json JsonPropertyName attributes.
  • Generate nullable property types when required.
  • Works with .NET Framework, .NET Core, .NET 8, .NET 9, and .NET 10.
  • No installation or registration required.
  • Free online JSON to C# class generator.

Keywords and Related Searches

Developers commonly use this tool when searching for:

  • JSON to C#
  • JSON to C# converter
  • JSON to C# class generator
  • Generate C# classes from JSON
  • Convert JSON to C# models
  • JSON to C# online
  • JSON to POCO converter
  • C# model generator from JSON
  • JSON to C# POCO classes
  • JSON to .NET class generator
  • Generate ASP.NET Core models from JSON
  • JSON to C# record generator
  • JSON schema to C# classes
  • System.Text.Json class generator
  • Newtonsoft.Json class generator
  • Convert API response to C# classes

This JSON to C# converter is designed for developers who need to transform API responses, configuration files, database exports, and other JSON structures into reusable C# classes.

Frequently Asked Questions

What is a JSON to C# converter?

A JSON to C# converter automatically generates C# class definitions from JSON data. It saves time by creating strongly typed models that can be used directly in .NET applications.

Is this JSON to C# class generator free?

Yes. The tool is completely free and can be used without registration or installation.

Can I generate C# classes from nested JSON?

Yes. Nested objects are automatically converted into separate C# classes with proper relationships.

Does the converter support JSON arrays?

Yes. Arrays are converted into appropriate collection types such as List<T>.

Can I use the generated classes in ASP.NET Core?

Absolutely. Generated classes can be used in ASP.NET Core Web APIs, MVC applications, Blazor projects, and other .NET solutions.

Does it support Newtonsoft.Json attributes?

Yes. You can generate JsonProperty attributes for compatibility with Newtonsoft.Json serialization and deserialization.

Does it support System.Text.Json attributes?

Yes. The tool can generate JsonPropertyName attributes for projects using System.Text.Json.

Can I convert API responses into C# models?

Yes. Simply paste the JSON response from an API and generate C# classes instantly.

Does the tool work with .NET 10 and .NET 9?

Yes. Generated C# classes are compatible with modern versions of .NET including .NET 8, .NET 9, and .NET 10.

What happens if my JSON is invalid?

The converter validates the JSON structure before generating classes. Invalid JSON must be corrected before conversion.

Can I generate nullable properties?

Yes. The generated classes can include nullable property types when the JSON structure allows null values.

Is my JSON data stored on the server?

No. Your JSON data is processed only for conversion purposes and is not permanently stored.

Can I use generated classes for deserialization?

Yes. Generated classes are ideal for deserializing JSON data using Newtonsoft.Json or System.Text.Json.

Can I generate POCO classes from JSON?

Yes. The converter creates clean POCO (Plain Old CLR Object) classes suitable for business applications and APIs.

Why use a JSON to C# class generator?

Generating classes automatically reduces coding errors, improves productivity, and ensures consistency when working with JSON data structures.

 Log In to Chat