Online JSON to C# Class Converter (Convert JSON to C# Class)

Online JSON to C# Class Converter, is a free tool to easily convert your JSON string or JSON object into C# class, so you can use them in C# code as classes.



How does JSON to C# Online Converter works?

We are using a NuGet package (NJsonSchema) which helps to convert JSON to C# class easily, if you want to permanently use it in your C# Code, you can use it.

Here are the steps to use NJsonSchema in your C# project to convert JSON string or object into C# Model:

  • Install NJsonSchema for .NET using Nuget
  • Use it as mentioned below:
                             string json = "{ "name":"John", "age":30, "car":null }";
    var schemaFromFile = JsonSchema.FromSampleJson(json);
    var classGenerator = new CSharpGenerator(schemaFromFile, new CSharpGeneratorSettings
    {
    ClassStyle = CSharpClassStyle.Poco,
    });
     //generated Class file
    var codeFile = classGenerator.GenerateFile();