DocumentsImagesMediaPDF Tools

JSON to C# Class

Generate C# classes from JSON, in your browser.

Processed in your browser

JSON to C# classes ready for .NET

Compatible with modern .NET

Generated classes work with System.Text.Json (.NET 5+) and Newtonsoft.Json. Ready for ASP.NET Core and .NET MAUI.

100% private

Your JSON is processed in the browser. Never sent to external servers. Safe for confidential APIs.

Idiomatic C# code

Auto-properties, PascalCase, correct nullable types. Code following official Microsoft conventions.

Instant

Class generation in milliseconds. No installations, no signup, no waiting.

Three steps, no hassle

1

Paste your JSON

Paste any valid JSON object. The parser detects types, optional fields, and nested structures.

2

Generate C# classes

C# classes are generated with auto-properties, nullable types for optional fields, and nested classes.

3

Copy and use in your project

Copy the generated code to Visual Studio or VS Code. Compatible with System.Text.Json and Newtonsoft.Json without modifications.

Got questions?

Auto-properties ({ get; set; }) are a C# feature that allows declaring properties without manually writing the backing field. Instead of declaring a private field and its explicit accessors, you simply write public string Name { get; set; } and the compiler generates the backing field automatically. This makes the code more concise and readable.

.NET naming conventions (documented in Microsoft's guidelines) specify that public properties should use PascalCase (PropertyName), unlike Java which uses camelCase. However, System.Text.Json and Newtonsoft.Json can automatically map between PascalCase in C# and camelCase in JSON using JsonPropertyName or serialization configuration.

When a field is present in some JSON objects but not others, it is inferred as optional and generated with a nullable type (string?, int?, bool?). This requires C# 8.0 or higher with nullable context enabled. Nullable types prevent NullReferenceException when accessing fields that may not be present in the JSON response.

Nested JSON objects are converted to separate C# classes in the same file. Each nested class is generated as a regular public class (not as an inner class), following the C# convention of one class per responsibility. References between classes are established through the property type.

System.Text.Json is included in .NET Core 3.0+ and is the recommended option for new projects: it's faster and requires no external dependencies. Newtonsoft.Json (Json.NET) has more features and is more flexible, being preferred when you need complex custom converters or compatibility with older projects. Classes generated by this tool are compatible with both without modifications.

C# classes, record types, .NET JSON serialization, and ASP.NET Core development

C# is the primary language of Microsoft's .NET ecosystem, used extensively for web APIs with ASP.NET Core, desktop applications with WPF/WinForms, and cross-platform applications with .NET MAUI. In REST API development with ASP.NET Core, data models (also called DTOs or view models) are C# classes that represent the body of JSON requests and responses.

With C# 9.0 and .NET 5+, Microsoft introduced record types: immutable classes with value-based equality, ideal for DTOs. Unlike regular classes, records are immutable by default and require less boilerplate code. However, for scenarios where objects must be mutable (for example, when deserializing from JSON), classes with auto-properties remain the standard option.

System.Text.Json, introduced in .NET Core 3.0, replaces Newtonsoft.Json as the recommended JSON serialization library. It is significantly faster and has a smaller memory footprint, which is important for high-performance APIs. In benchmarks, System.Text.Json outperforms Newtonsoft in serialization and deserialization speed. Convertir.ai generates classes compatible with both libraries, processing everything in your browser without sending data to servers.