Free tools that run in your browser. Use any tool without an account.

Favourites Cart
Sign in
Join free

JSON to C# Class Converter

  • Free
  • Runs in your browser
  • No account needed

This tool converts JSON into ready C# classes using System.Text.Json or Newtonsoft.Json attributes; runs in your browser, copies with one click, and lets you open or download the generated .cs file.

JSON to C# Class Converter runs in your browser. Your text is never uploaded or stored.

Runs in your browser. Your files and values are not sent to us. Report a problem
Advertisement

About the JSON to C# Class Converter

This is a free, browser-side tool that turns a JSON sample into C# class code you can paste into a project. You choose System.Text.Json or Newtonsoft.Json attributes. The converter runs entirely in your browser and does not upload what you type. You can copy the output with one click, open a file to load JSON, or download the generated .cs file. Developers use it for DTOs, quick prototypes, API clients, and unit tests. Compared with heavier generators it stays simple: it infers types for strings, numbers, booleans, arrays and nested objects so you get usable POCOs quickly and can adjust edge cases by hand.

How to use it

  1. 1Paste your JSON sample into the input area.
  2. 2Select System.Text.Json or Newtonsoft.Json for attribute style.
  3. 3Click Convert to generate C# classes.
  4. 4Click Copy to copy the code or Open/Download to save a .cs file.
Advertisement

Worked example

Input JSON: { "id": 42, "name": "Widget", "price": 19.95, "tags": ["sale","new"], "created": "2021-09-01T12:00:00Z" } Generated C# (System.Text.Json): public class Root { [JsonPropertyName("id")] public int Id { get; set; } [JsonPropertyName("name")] public string Name { get; set; } [JsonPropertyName("price")] public double Price { get; set; } [JsonPropertyName("tags")] public List<string> Tags { get; set; } [JsonPropertyName("created")] public DateTime Created { get; set; } }

How it works

Text tool that runs in the browserOptions: System.Text.Json, Newtonsoft.JsonOne click copies the outputVisitors can also open a file and download the resultNothing typed is uploaded

Source: RFC 8259 JSON specificationMicrosoft System.Text.Json guideJSON Schema specifications. Last checked 6 November 2026.

What it is good for

  • Runs entirely in your browser; no uploads.
  • Produces copy-paste ready C# with attribute choice.
  • One click copy and .cs file open or download.
  • Infers types from the sample and may need manual fixes for ambiguous cases.
  • Not a schema-driven generator; it uses example-based heuristics.
Advertisement

Questions people ask

Will my JSON be sent to a server?

No. The converter runs in your browser and does not upload what you type. If you need legal certainty for sensitive data, avoid pasting personal data and use local tools or your company approved workflows.

Which serializer attributes can I choose?

You can choose System.Text.Json attributes such as JsonPropertyName or Newtonsoft.Json attributes such as JsonProperty. Pick the attribute style that matches your project and serializer API.

How does the tool decide types for numbers and dates?

The tool uses simple heuristics. Integers map to int when values fit 32 bits, decimals map to double by default, and ISO 8601 strings map to DateTime when recognized. Review and adjust types for edge cases.

How are nulls represented in generated classes?

Null values produce nullable reference or nullable value types when the sample shows null. If a property is only null in the sample, the tool may default to a nullable string or object and you should confirm the correct type.

Can I load a JSON file and download the generated .cs file?

Yes. You can open a local JSON file in the tool and, after conversion, download the generated .cs file to your device. The file operations happen in your browser.

Will it handle complex heterogeneous arrays or schemas?

The tool infers a single element type for arrays based on the sample. For heterogeneous arrays or formal schemas, use a schema-aware generator like quicktype or a schema-to-code tool for more precise types.

Help keep every tool free

FreeToolr stays free because people help it grow. Share a tool you like, tell us what to build next, or support us on Ko-fi.

Advertisement
Advertisement