JSON Input

C# Output

What Is JSON to C#?

C# uses classes and properties to represent data. When you consume JSON from an API or config, you need matching C# types for deserialization. This tool generates C# classes (POCOs) from your JSON. Paste sample JSON and get class definitions with the right property types. Use them with System.Text.Json or Newtonsoft.Json.

Conversion runs in your browser. Use the config options to set the class name, choose properties vs fields, and enable nullable types. Nothing is sent to a server.

How to Use This Tool

1

Paste JSON

Paste your JSON into the left editor or upload a file. Use Sample for example data. Set the root class name and options (Properties, Nullable) in the config panel.

2

Review the Classes

The right panel shows generated C# classes. Nested objects become separate classes. Arrays become List<T> or T[]. Add [JsonPropertyName] attributes if needed for different JSON key names.

3

Copy or Download

Use Copy or Download to get the code. Paste into your .NET project. For formatting JSON first, use the JSON Formatter. For validation, use the JSON Validator.

JSON to C# Examples

Here is an example of generating C# classes from a JSON object.

Example: Subscriber record

JSON input:

Input

Generated C# output:

Output

When JSON to C# Helps

When integrating REST APIs in .NET, ASP.NET Core, or Blazor, you need C# types for deserialization. Pasting a sample response here gives you POCOs you can use with JsonSerializer.Deserialize<T>() or Newtonsoft.Json. For API testing, Postman and jq are useful. For pulling out specific values from large responses first, use the JSON Path tool.

Frequently Asked Questions

Properties vs fields?

Properties use get; and set;. System.Text.Json and Newtonsoft.Json serialize properties by default. Fields work but are less common for DTOs.

What about nullable reference types?

Enable Nullable Types in the config to get string? etc. Useful for optional JSON fields. Requires nullable context in your project.

Is my data sent anywhere?

No. Generation runs in your browser.

Can I use this with System.Text.Json?

Yes. The generated classes work with JsonSerializer.Deserialize<T>(). Add using System.Text.Json.Serialization; if you need custom attributes.

What if my JSON keys don't match C# naming?

Use [JsonPropertyName("json_key")] on the property, or configure JsonSerializerOptions.PropertyNamingPolicy to camelCase.

Related Tools

System.Text.Json. Newtonsoft.Json. JSON spec. RFC 8259. MDN. .NET. Postman.