🟪

JSON to C# Class Converter

Software · 2 inputs · Free

🟪

JSON to C# Class Converter

2 inputs

Parameters

What is this tool?

JSON to C# Class Converter helps developers with encoding, encryption and text processing. Generates C# classes for System.Text.Json from a JSON sample: PascalCase properties with [JsonPropertyName] attributes, int/long/double/bool/string, List<T>, and a separate class for every nested object. Fields that can be null or are missing from some elements are marked T?; the code compiles without warnings under #nullable enable.

📘 Common mistakes · Worked example
JSONRoot class name

Generates C# classes for System.Text.Json from a JSON sample: PascalCase properties with [JsonPropertyName] attributes, int/long/double/bool/string, List<T>, and a separate class for every nested object. Fields that can be null or are missing from some elements are marked T?; the code compiles without warnings under #nullable enable.

The result is not exact or binding and is for information only; it is not an official document and cannot be used in official procedures. Confirm it with the competent authority or a professional before acting; no liability is accepted for losses arising from its use.

Last reviewed: · Methodology and sources

How is it calculated?

Generates C# classes for System.Text.Json from a JSON sample: PascalCase properties with [JsonPropertyName] attributes, int/long/double/bool/string, List<T>, and a separate class for every nested object. Fields that can be null or are missing from some elements are marked T?; the code compiles without warnings under #nullable enable.

Inputs

ValueUnitExample
JSON—{"id":1,"user_name":"Ada","email":"ada@example.com","score":9.5,"active":true,"tags":["a","b"],"address":{"city":"Berlin","zip":null},"orders":[{"order_id":7,"paid":true},{"order_id":8,"note":"gift"}]}
Root class name—Root

What is this tool?

JSON to C# Class Converter helps developers with encoding, encryption and text processing. Generates C# classes for System.Text.Json from a JSON sample: PascalCase properties with [JsonPropertyName] attributes, int/long/double/bool/string, List<T>, and a separate class for every nested object. Fields that can be null or are missing from some elements are marked T?; the code compiles without warnings under #nullable enable.

Common mistakes

  • Deleting the attributes and expecting names to match on their own. System.Text.Json is case-sensitive by default; html_url does not match HtmlUrl and the property silently stays empty.
  • Relying on a string property never being null. Nullability annotations belong to compile time; with default settings a JSON null is assigned to a string property, and the first use may throw a NullReferenceException.
  • Reading the initialisers as "this field is required". = ""; and = new(); only silence a compiler warning; nothing fails when the field is absent. Use required or [JsonRequired] to enforce presence.
  • Leaving money amounts as double. The tool writes double for every decimal number, and binary floating point cannot represent values such as 0.1 exactly. Change amount fields to decimal by hand.
  • Trusting classes generated from a single record. With one element in an array no field becomes T?; the tool can only notice that a field is sometimes missing when it sees several records.
  • Leaving object? and List<object> lines as they are. They only say that null was all the tool saw, or that the array was empty or mixed; find out the real type and write it in.
  • Reading integers that do not fit in a long as double. Most integers above 9223372036854775807 cannot be held exactly in a double; make such fields decimal or string.

📘 JSON to C# Classes: JsonPropertyName and Nullable Reference Types →

Sources

Key terms

JSONRoot class name

Frequently Asked Questions

+JSON to C# Class Converter — how is it calculated?

Generates C# classes for System.Text.Json from a JSON sample: PascalCase properties with [JsonPropertyName] attributes, int/long/double/bool/string, List<T>, and a separate class for every nested object. Fields that can be null or are missing from some elements are marked T?; the code compiles without warnings under #nullable enable.

+Which values are required?

JSON, Root class name.

+Is my data stored?

No. All calculations run in your browser; the values you enter are never sent to or stored on a server. If you press “Save”, the calculation stays only in your own browser and you can delete it at any time.

+Is it free?

Yes, all tools are free and require no sign-up.

Similar tools

Popular Tools

🧮

Free Calculators in One Place

Tax, finance, health, math and more — 500+ tools, all in one place.

Choose your cookie preference to continue

Records the site needs to work (theme, language, favourites) stay in your browser.

This site is free and funded by ads.

With your consent, Google Analytics cookies measure visits and Google AdSense cookies are used to show ads; the data is processed on Google servers abroad.

If you reject, the site works just the same.

Cookie Policy · KVKK notice