C# to JSON

Convert C# model classes to JSON objects

The rules:

  • Must supply valid C# code, ideally just classes and structs that expose public properties (methods, statics, and any other application code will be ignored).
  • If a class references other object types, include those dependency classes or enums too.
  • If you want your JSON to be populated with sample data, initialize those properties directly (without getters and setters) or create a default constructor and set them there.
  • Commonly used namespaces (System.Collections.Generic, System.Linq, etc) are automatically included; however, for less commonly used .NET Framework types you may add those namespaces. Example: to use the type IPAddress include "Using System.Net;".
  • If it doesn't compile in Visual Studio it won't compile here.
See the example below and click the button to try it out.
Note: This tool is intended to consume reasonably simple C# class hierarchies that have no dependencies on external libraries. Anything too complex may generate errors.

  Camel case
  Generate comments