C# to JSON Converter
Paste C# classes or objects. Get clean JSON back.
Input
Output
Paste your C# code on the left and press Convert.
Or drop a file on this box, , or .
What this tool does
Test fixtures, Swagger examples and Postman bodies all end up as JSON that has to match a C# model, and typing them by hand is where the typos creep in. Paste a class and an object initializer here and the backend returns the JSON for that object, nested Address and List<OrderItem> members included. A lone initializer, a whole Models.cs or a deep object graph all go through the same way.
The backend aims for what a .NET serializer would write, not a text swap: 249.99m loses its m and becomes a number, DateTime and DateTimeOffset are written as ISO 8601 text inside an RFC 8259 document, a Guid stays a quoted string, a nullable holding nothing becomes null, and collections follow System.Text.Json and Newtonsoft.Json: List<T> and arrays as arrays, Dictionary<string,V> as an object.
Attributes count as well. [JsonPropertyName("order_id")] changes the key and [JsonIgnore] leaves the property out. With several classes in one paste, every class becomes a separate entry at the top of the output, child types are written out where they are referenced, and a derived class carries the properties it inherits.
How to use it
A five-line DTO and a forty-class domain project go through the same three steps.
Paste your C# (or try the sample)
Paste the C# straight from Visual Studio or Rider into the left editor: class definitions, a var order = new Order { ... } initializer, records, nested types. Load Sample loads an Order with decimal prices, a List<OrderItem> and an Address, so you can see the result before trying your own code.
You do not need to clean up the code: leave the C# syntax, access modifiers, and attributes as they are. Just paste.
Hit Convert
Click the green Convert button to post the code to the backend. It resolves the initializer against the class definitions and replies with JSON, and a "Converting..." overlay stays up until then.
Copy the JSON
The right panel fills with indented, MDN-compatible JSON. Copy it straight into your API request, test fixture, config file, or documentation.
When this actually comes in handy
Building API fixtures
You have a C# request model and need a JSON payload to drop into Postman or curl. Paste the class, get the JSON, move on.
Starting config files
A Settings class with 40 properties turns into a ready-to-edit JSON template for appsettings.json or any config store, no handwritten boilerplate.
Keeping docs in sync
Generate JSON examples for a README, API reference, or OpenAPI spec straight from your actual models, so the docs match the code.
Seeding test data
Object initializers in xUnit or NUnit tests already describe valid entities. Convert one and keep it as JSON seed data for an integration test, a WireMock stub or an EF Core data loader.
Common questions
Can I paste multiple classes at once?
Yes. A complete file works: each top-level class with data turns into a key of its own, nested objects are expanded in place, and properties from a base class show up on the class that inherits them.
Does it honour attributes like [JsonPropertyName] or [JsonIgnore]?
Yes. [JsonPropertyName("x")] and [JsonProperty("x")] rename the JSON key, and [JsonIgnore] removes the property from the output: the same behaviour you would get from System.Text.Json.
How does it handle decimal, DateTime, Guid, and the usual C# types?
49.99m drops the suffix and is written as a number. DateTime and DateTimeOffset appear as ISO 8601 text such as "2026-03-14T10:30:00+00:00". A Guid keeps its usual dashed, quoted form, TimeSpan becomes a string like "00:30:00", and a nullable is either null or its inner value.
What about nested classes, lists, and dictionaries?
List<T>, arrays, HashSet<T>, and IEnumerable<T> all become JSON arrays. Dictionary<K,V> becomes a JSON object. Nested object initializers (an Address inside an Order, for example) are expanded as nested JSON objects with every field intact.
Is my code stored?
It goes to the backend for that one conversion and is not kept. Connection strings and API keys like to hide in default property values and const fields, so check for those before pasting.
What if the C# has something unusual: methods, delegates, IntPtr?
Members with no data shape, such as methods, delegates or an IntPtr, come out as null instead of stopping the run, so the rest of the model still converts. Code that would not compile in the first place can confuse the read, so clear the red squiggles in your IDE first.
Other tools you may need
These pick up where the C# conversion stops: JSON to C# for the reverse trip when an API hands you a payload, TypeScript types for the frontend that consumes it, and the usual checks on the output: