Json2Sharp 1.3.0

dotnet add package Json2Sharp --version 1.3.0
                    
NuGet\Install-Package Json2Sharp -Version 1.3.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Json2Sharp" Version="1.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Json2Sharp" Version="1.3.0" />
                    
Directory.Packages.props
<PackageReference Include="Json2Sharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Json2Sharp --version 1.3.0
                    
#r "nuget: Json2Sharp, 1.3.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Json2Sharp@1.3.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Json2Sharp&version=1.3.0
                    
Install as a Cake Addin
#tool nuget:?package=Json2Sharp&version=1.3.0
                    
Install as a Cake Tool

NuGet Badge NuGet Nightly Badge

Json2Sharp

Json2Sharp is a library that converts a JSON object to a class definition (or an equivalent for the target language).

To perform a conversion, call the Parse method from the Json2Sharp class.

string code = Json2Sharp.Parse("Person", """{ "id": 1, "name": "John" }""");
/*
 * using System.Text.Json.Serialization;
 *
 * public sealed record Person(
 *     [property: JsonPropertyName("id")] int Id,
 *     [property: JsonPropertyName("name")] bool Name
 * );
 */

You can also customize the conversion by initializing a Json2SharpOptions object and populating its members to suit your needs.

Json2SharpOptions options = new()
{
    TargetLanguage = Language.CSharp,
    CSharpOptions = new()
    {
        IsSealed = false,
        IsPropertyRequired = false,
        TargetType = CSharpObjectType.Class,
        SerializationAttribute = CSharpSerializationAttribute.NewtonsoftJson
    }
};

string code = Json2Sharp.Parse(className, rawJson, options);
/*
 * using Newtonsoft.Json;
 *
 * public sealed class Person
 * {
 *     [JsonProperty("id")]
 *     public int Id { get; init; }
 *
 *     [JsonProperty("name")]
 *     public string Name { get; init; }
 * }
 */
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.3.0 100 3/8/2026
1.3.0-nightly-077 70 3/8/2026
1.3.0-nightly-076 66 3/8/2026
1.2.1-nightly-075 75 3/8/2026
1.2.1-nightly-074 66 3/8/2026
1.2.1-nightly-073 69 3/8/2026
1.2.1-nightly-071 76 3/7/2026
1.2.0 83 3/7/2026
1.2.0-nightly-070 65 3/7/2026
1.2.0-nightly-069 59 3/7/2026
1.2.0-nightly-068 66 3/7/2026
1.2.0-nightly-067 69 3/7/2026
1.2.0-nightly-066 72 3/4/2026
1.2.0-nightly-065 77 3/3/2026
1.2.0-nightly-064 72 3/3/2026
1.2.0-nightly-063 80 3/3/2026
1.2.0-nightly-062 76 3/3/2026
1.2.0-nightly-061 69 3/1/2026
1.2.0-nightly-060 70 3/1/2026
1.2.0-nightly-059 77 3/1/2026
Loading failed