Skip to content

JSON to C# Classes for .NET

Open or paste JSON and C# classes for it appear at once, ready to copy or download as .cs; nothing is uploaded.

Processed on your device. Nothing is uploadedHow to check

Try a sample file:

You can also paste JSON with Ctrl+V (⌘+V on a Mac).

Your file is opened in this browser tab only: it is never uploaded or stored anywhere, and it is gone when you close the tab.

  • JSONView and edit.json

Also works with CSV, TXT, Excel, Word, PDF, Image, and PowerPoint files

Paste text instead

Pasted text stays in this tab and is never sent anywhere.

Deserializing JSON in .NET goes faster when the model classes are already there. Open or paste a response and the page writes a public partial class for every object in it, inside namespace Example: PascalCase properties such as public long Id { get; set; }, long or double depending on the numbers in the sample, arrays such as string[] or Project[], and nullable types such as string? where some items leave a key out. Copy the classes into your project or download a .cs file. They are generated in your browser; the response is never uploaded.

Why use JSON to C#

  • Private

    Your JSON is read and the classes are written by your own browser; nothing is sent to a server.

  • Plain .NET classes

    Partial classes with PascalCase get/set properties and no attributes, ready for System.Text.Json.

  • Works offline

    After you have used it once, it keeps working without an internet connection.

How it works: generate C# classes from JSON

  1. Open or paste a response

    Paste JSON into the box, drop or choose a .json file, or try a sample.

  2. Read the classes

    The C# code is shown at once, one class per kind of object, with a property for every key.

  3. Add them to your project

    Copy the code or download a .cs file, change namespace Example to yours, and deserialize into Root.

What the JSON to C# generator handles

  • Properties: { get; set; } properties named in PascalCase, in public partial classes.
  • Numbers: long for whole numbers, double when a value has a decimal part.
  • Keys missing from some items: nullable types such as string? or bool?.
  • Arrays: typed by their items, such as string[] or Project[]; objects in one array merge into one class.
  • A value that is null everywhere in the sample becomes object.
  • Input from a .json file, a drop, the paste box or a sample, up to 10 MB.

JSON to C#: what it can't do

  • No attribute keeps the original JSON name; camelCase or snake_case keys need serializer options to match the PascalCase properties.
  • Types come from one sample: a property that is null in every item becomes object.
  • Numbers become long or double; switch to int or decimal by hand where your domain needs it, such as money.
  • Very large documents may take a few seconds; files up to 10 MB.

JSON to C# classes: questions and answers

Is my file uploaded?
No. The JSON is read and the C# code is generated by your browser, on your device. Pasted text stays in this tab and is never sent anywhere.
How do the classes handle nullable reference types?
Keys missing from some items get nullable types, such as string? or bool?. With <Nullable>enable</Nullable> in your project, read the compiler's warnings on the other reference properties and add ? or a default where your data can be empty.
My JSON uses camelCase keys. How do they bind to PascalCase properties?
The classes carry no attributes, so tell the serializer. With System.Text.Json, set PropertyNameCaseInsensitive = true or PropertyNamingPolicy = JsonNamingPolicy.CamelCase in JsonSerializerOptions, and "orderId" fills OrderId.
Why is a price typed double and not decimal?
JSON does not say which numeric type to use, so decimals become double. For money, change those properties to decimal by hand.
Can I paste a JSON array of records?
Yes. The items are merged into one class: keys present in every item keep their plain type, keys missing from some items become nullable. Deserialize into an array of that class.
Does it make records or classes?
Partial classes with get and set properties, which every .NET version and serializer reads. Turning them into records is a short edit if your project prefers them.
How do I convert JSON to C# classes?
Paste a JSON sample into OpenAnyDoc's JSON to C# generator and the classes appear at once, one per kind of object with a property for every key. Copy them or download a .cs file, change the namespace to yours and deserialize into Root; the JSON stays in your browser.

Why it's private: your files never leave your browser

Most online viewers upload your file to a server, so a copy of it leaves your device. OpenAnyDoc works the other way round: your browser reads the file and draws it on your screen. Nothing is uploaded, there is no account, and the file is gone from memory when you close the tab, so there is nothing for us to store, see or lose.

How we tell you about new features

Announcements are based on the release date shown to everyone, and nothing is stored on your device or sent anywhere.