JSON to C# Classes
Enter JSON:


Property Settings

Attributes/Decorators





C# Classes
          



How to convert from JSON to C# using the online converter?

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:
    {
                "Class11":{
                    "id":4,
                    "user_id":"user_id_value",
                    "awesomeobject":{
                    "SomeProps1":1,
                    "SomeProps2":"test"
                },
                "created_at":"2022-06-02T23:33:30Z",
                "updated_at":"2022-06-02T23:33:30Z",
                "users":[
                    {
                    "id":"6",
                    "name":"Test Child 1",
                    "created_at":"2022-06-02T23:33:30Z",
                    "updated_at":"2022-06-02T23:33:30Z",
                    "email":"test@gmail.com"
                    },
                    {
                    "id":"6",
                    "name":"Test Child 1",
                    "created_at":"2022-06-02T22:33:30.345Z",
                    "updated_at":"2022-06-02T23:33:30",
                    "email":"test@gmail.com",
                    "testanadditionalfield":"tet"
                    } ]
                },
                "Class12":{
                "SomePropertyOfClass12":"SomeValueOfClass2"
                }
            }
  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 retuned 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:
    public class RootObject
            {
                public Class11 Class11 { get; set; }
                public Class12 Class12 { get; set; }
            }
            public class Awesomeobject
            {
                public int Someprops1 { get; set; }
                public string Someprops2 { get; set; }
            }
    
            public class Users
            {
                public string Id { get; set; }
                public string Name { get; set; }
                public DateTime CreatedAt { get; set; }
                public DateTime UpdatedAt { get; set; }
                public string Email { get; set; }
            }
    
            public class Class11
            {
                public int Id { get; set; }
                public string UserId { get; set; }
                public Awesomeobject Awesomeobject { get; set; }
                public DateTime CreatedAt { get; set; }
                public DateTime UpdatedAt { get; set; }
                public List<Users> Users { get; set; }
            }
    
            public class Class12
            {
                public string Somepropertyofclass12 { 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.
  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.

Blog

 Log In to Chat