JSON to C# Class

Oct 24, 2018

JSON to C# Class tool creates Newtonsoft annotated C# model or stub classes from JSON document. You can select the property naming convention and whether or not to annotate the properties.



Input: Paste JSON content below

Settings

Output: Generated Classes


Generate annotated POJO or stub classes from JSON text, document, file or data

View Tool

Generate C# Class from JSON

Use this tool to quickly generate model classes for C# from a sample JSON document. The csharp model class is annotated using JsonProperty attribute supplied by Newtonsoft.

JSON

JavaScript Object Notation (JSON), pronounced as Jason, is the most common data interchange format on the web. Douglas Crockford first released the JSON specification in the early 2000s. It is a simple format that is easier to comprehend than XML. It is also smaller in size because it does not have closing tags. A wide variety of programming languages can parse JSON files. They also support the serialization of data structures to JSON. You can copy JSON text to JavaScript and start using them without any modifications.

Settings Explained
  • 1. Annotate

    If selected, properties are annotated using Newtonsoft.Json's JsonProperty attribute.

    Annotate On

    public class Person
    {
        [JsonProperty("fullName")]
        public string fullName { get; set; }
    
        [JsonProperty("age")]
        public int age { get; set; }
    }
    Annotate Off

    public class Person
    {
        public string fullName { get; set; }
        public int age { get; set; }
    }
  • 2. Property Naming Strategy

    Choose the naming strategy of the generated properties. The available options are:-

    Cleanse Only

    public class Person
    {
        [JsonProperty("Full Name")]
        public string FullName { get; set; }
    
        [JsonProperty("age")]
        public int age { get; set; }
    }
    Pascal Case

    public class Person
    {
        [JsonProperty("Full Name")]
        public string FullName { get; set; }
    
        [JsonProperty("age")]
        public int Age { get; set; }
    }
    Camel Case

    public class Person
    {
        [JsonProperty("Full Name")]
        public string fullName { get; set; }
    
        [JsonProperty("age")]
        public int age { get; set; }
    }
Comments 0

History
Jan 18, 2018
Assumed data type to be string in case of empty arrays
Sep 5, 2017
Tool Launched