ToolBuddy
In Browser

JSON to C#

Infer C# records from a JSON sample. Nested objects become public records with System.Text.Json attributes. Keys missing from some objects in an array are optional. Conversion stays in the tab.

Runs in your browser. Nothing is uploaded.

0 characters · 0 lines

0 characters · 0 lines

About this tool

Infer C# records from a JSON sample. Objects become public records. When the C# name differs from the key, the property gets JsonPropertyName. Keys missing from some objects in an array, and a JSON null next to a concrete value, become nullable. Whole numbers stay long. Other numbers become double.

How to use: paste JSON, copy the records. A root array of objects is written as a comment that Root is List<RootItem>, plus the item record. Empty objects become Dictionary<string, object?> and empty arrays become List<object?>. This is a starting point. It does not add methods, constructors, or validation attributes.

Example: {"id":1,"name":"Ada","address":{"city":"London"}} yields record Root and record Address. The snippet expects System.Text.Json. Related: JSON to Java for records, JSON to TypeScript for interfaces, JSON to Go for structs.

The sample stays in the tab. Nothing is uploaded. After the page loads, conversion works offline.

FAQ

Related Convert tools