Generate C# classes from JSON Schema [closed] Generate C# classes from JSON Schema [closed] json json

Generate C# classes from JSON Schema [closed]


Visual Studio 2017 has this feature.

From the menu, choose Edit, Paste Special, Paste JSON As Classes. Paste in the JSON and Visual Studio will create the required classes.

enter image description here


Look up this library on nuget. The NJsonSchema.CodeGeneration can be used to generate C# or TypeScript code from a JSON schema:

var generator = new CSharpGenerator(schema);var file = generator.GenerateFile();

The file variable now contains the C# code for all the classes defined in the JSON schema.


You can use the library NJsonSchema to read a JSON schema or generate one from a type, and generate a C# class from it.

If you need a GUI for these tasks, you can try the NSwagStudio GUI from the NSwag tools to do so... (it is also based on NJsonSchema)