Skip to content

JSON to C# Class

Generate C# classes with System.Text.Json attributes from a JSON sample.

Leave them off if your serialiser is configured with a camelCase naming policy and the mapping is implicit.

Quick Tool Overview

The JSON to C# Class converter writes model classes with PascalCase properties, JsonPropertyName attributes carrying the original keys, List<T> collections and nullable value types wherever a field can be absent.

What it does
Generates C# model classes from a JSON sample
You give it
A JSON payload, ideally an array of records
You get back
Classes ready for System.Text.Json deserialisation
Best for
Consuming a REST API from .NET without hand-written models
Developer Tools Free, unlimited use No sign-up Runs in your browser

About the JSON to C# Class

Paste a payload and get the model classes: PascalCase properties with getters and setters, a JsonPropertyName attribute carrying the original key, List<T> for arrays and a nested class for every nested object.

Optional fields are declared as nullable value types — long?, double?, bool?, DateTime? — so an absent key deserialises as null rather than silently becoming zero. Values that look like timestamps are typed as DateTime, numbers as long or double depending on whether a decimal point appears anywhere in the sample, and you can drop the attributes entirely if your serialiser is configured with a camelCase naming policy instead.

Key features of the JSON to C# Class

Explicit key mapping

JsonPropertyName preserves the original JSON key, so PascalCase properties bind correctly however the API names its fields.

Nullable value types

long?, double? and bool? are used where a key can be missing, so an absent number does not silently deserialise as zero.

DateTime where it fits

Values in ISO 8601 form are typed as DateTime rather than string, which is what you actually want to work with.

Attributes are optional

Drop them entirely when your serialiser is configured with a camelCase naming policy and the mapping is implicit.

Newtonsoft in two edits

Swapping JsonPropertyName for JsonProperty and the using directive is all it takes if your project is on Newtonsoft.Json.

How to use the JSON to C# Class

  1. 1

    Paste the JSON

    An array of records detects optional fields better than a single object.

  2. 2

    Name the root class

    Nested classes are named from the keys that contain them.

  3. 3

    Choose the attributes

    Keep JsonPropertyName for explicit mapping, or drop it if you use a naming policy.

  4. 4

    Copy into your project

    Paste into a .cs file — the using directives are included.

Frequently asked questions

The output targets System.Text.Json, the built-in serialiser since .NET Core 3.0. For Newtonsoft.Json, swap JsonPropertyName for JsonProperty and the using directive for Newtonsoft.Json — nothing else changes.

Reviews of the JSON to C# Class

What people who use the JSON to C# Class think of it. Reviews come from visitors and are posted as written.

No ratings yet

Yours would be the first.

  • 5 0 reviews rated 5 stars
  • 4 0 reviews rated 4 stars
  • 3 0 reviews rated 3 stars
  • 2 0 reviews rated 2 stars
  • 1 0 reviews rated 1 star

Write a review

Used this tool? Your rating helps the next person decide.

Your rating

Plain text only — links, email addresses and HTML are not accepted. Your name and review are shown publicly; nothing else is collected. See the privacy policy.

0 reviews

Newest first

No reviews yet

Be the first to rate the JSON to C# Class. It takes half a minute and no account.

Write the first review

More developer tools