API Toolkit

JSON to C#

All tools

Get model classes for a .NET client from one example payload.

How it works

Four simple steps

1

Paste the payload

Use one JSON object as the sample.

2

Classes are emitted

Each object becomes a class with JsonProperty attributes.

3

Adjust the types

Change int to long or add nullability where needed.

4

Save Model.cs

Copy the code or download the file.

JSON to C#

About JSON to C#

An ASP.NET service needs to call a partner API, and all you have is a sample payload pasted into their onboarding email. Rather than writing the DTOs field by field, paste the payload here and start from generated classes.

Each JSON object becomes a public class with auto-properties. Property names are converted to PascalCase, and each one carries a [JsonProperty("originalName")] attribute so Newtonsoft.Json maps camelCase or snake_case keys correctly. Whole numbers become int, decimals become double, booleans become bool and text becomes string. Arrays become List<T>, using the first element to decide T, and nested objects get their own class named after the key. The file starts with using directives for System.Collections.Generic and Newtonsoft.Json and can be downloaded as Model.cs.

A few things need a manual pass. Ids that exceed the int range should be long. A null value in the sample is typed as string, and an empty array as List<object>. If your project uses System.Text.Json instead of Newtonsoft, swap the attribute for [JsonPropertyName] and change the using directive. The root has to be an object, so for a top-level array paste a single element. If the payload will not parse, the JSON validator shows where it breaks, and the same sample can produce Java model classes for another team.

The classes are generated in your browser, and the payload is not transmitted anywhere.

Keyboard shortcut

Ctrl Enter - Run tool
FAQ

Frequently asked questions

See all FAQs

Answers for this tool. For site-wide help, open the FAQ hub.

The generator expects an object at the root and walks its keys, so an array's indexes end up as property names. Paste one element of the array instead and use List in your code.

No. Properties are written as plain types. Add ? to properties that can be missing or null once you know the API contract.

The output uses classes with get and set accessors. Converting to a record is a quick edit, but keep the JsonProperty attributes on the properties so deserialization still maps the keys.

View more FAQs

Related tools

View all

Webhook HMAC Signer

Sign and verify GitHub, Stripe, and Slack webhook signatures locally.

Open

Webhook Replay Diff Lab

Compare webhook payload timelines, re-check HMAC digests, and spot idempotency gaps locally.

Open

JSONPath Playground

Query JSON with JSONPath and JMESPath-style paths side by side.

Open

GraphQL Studio

Format, validate, and cost-estimate GraphQL documents with cURL export.

Open

Explore 321 free tools

Everything you need as a developer, marketer or creator - in one beautiful place.

Browse all tools