JSON to C# Converter Online — Generate POCO Classes

Generate C# POCO classes from any JSON payload — public properties, nullable types, optional [JsonProperty] attributes, and nested classes. 100% in your browser.

What is a JSON to C# converter?

A JSON to C# converter reads a JSON sample and emits typed Plain Old CLR Objects (POCOs) that mirror the JSON shape — public auto-properties, nullable annotations, nested classes, and the right primitive or value types. The output drops straight into an ASP.NET Core, Blazor, MAUI, or Unity project and deserializes with System.Text.Json or Newtonsoft.Json without manual wiring.

Writing model classes by hand from a 200-field API payload wastes hours and is bug-prone — a single typo in a property name silently nulls out a value at runtime. OpenFormatter's converter walks the JSON tree once, generates idiomatic C#, and runs entirely in your browser so internal API responses never leave your machine.

How to generate C# POCOs from JSON — 4 steps

  1. Paste a real JSON response. Use a representative sample — type inference quality depends on it. Booleans must be true/false (not 0/1), numbers must be unquoted.
  2. Click Convert. The tool emits a Root class plus one separate class per nested object, with public auto-properties.
  3. Copy and paste into your IDE. Each class is independent — split them across files in your MyApp.Models namespace.
  4. Deserialize. var root = JsonSerializer.Deserialize<Root>(json); — that is all System.Text.Json needs once the POCO has auto-properties and a default constructor.

JSON to C# type mapping

Sample JSON

{
  "id": 42,
  "name": "Ada Lovelace",
  "active": true,
  "score": 98.5,
  "address": { "city": "London" },
  "tags": ["admin", "engineer"]
}

Generated C# POCO

using System.Collections.Generic;
using System.Text.Json.Serialization;

public class Root
{
    public int Id { get; set; }
    public string Name { get; set; }
    public bool Active { get; set; }
    public double Score { get; set; }
    public Address Address { get; set; }
    public List<string> Tags { get; set; }
}

public class Address
{
    public string City { get; set; }
}

Idiomatic POCOs

Public auto-properties, default constructors, PascalCase naming — exactly what System.Text.Json and Newtonsoft.Json expect for reflection-based deserialization.

Nested classes

Every nested JSON object becomes its own typed class so you can split files across the Models namespace and see the full hierarchy at a glance.

Client-Side Only

JSON is parsed in JavaScript inside the browser. Internal API responses, tokens, or PII never reach a server.

Common use cases

  • check_circleGenerating ASP.NET Core Web API request and response DTOs from a frontend JSON payload
  • check_circleBuilding System.Text.Json deserializable models for a third-party REST API (Stripe, Slack, GitHub)
  • check_circleProducing MAUI or Xamarin response bodies from a JSON spec
  • check_circleGenerating Blazor Server / Blazor WebAssembly view models from JSON
  • check_circleModelling Azure Service Bus, RabbitMQ, or Kafka JSON event payloads as typed POCOs
  • check_circleBuilding Azure Functions or AWS Lambda request/response classes
  • check_circleGenerating Unity 3D save-game or network-protocol POCOs
  • check_circleModelling appsettings.json sections into typed IOptions<T> classes

Why client-side generation matters

The JSON you paste often contains real customer data, OAuth tokens, signed URLs, or internal field names you do not want indexed by a third-party converter. OpenFormatter generates the C# entirely in JavaScript on your device — open the Network tab in DevTools and you will see zero requests when you click Convert. Safe for enterprise use, safe behind a corporate proxy, safe when the API contract is itself confidential.

Need other C# tooling?

Format C# source, parse JSON inside C# code, or generate types for other languages — all browser-side.

Frequently Asked Questions

POCO with [JsonProperty] or System.Text.Json defaults?

The generator emits a clean POCO that works with both System.Text.Json (the .NET 5+ default) and Newtonsoft.Json out of the box because property names are PascalCase mapped from the JSON key. For JSON keys that do not match a valid C# identifier — or to preserve a snake_case wire format — annotate the property with [JsonPropertyName("original_key")] for System.Text.Json or [JsonProperty("original_key")] for Newtonsoft.

Are nullable reference types used?

Yes. With <Nullable>enable</Nullable> set in your .csproj, JSON null values produce nullable reference types like string? and the generator emits object? for fields whose value is JSON null. Non-null sample values produce non-nullable string and value types like int and bool, which matches the C# 8+ nullable annotation contract.

How do I deserialize the generated POCO?

With System.Text.Json: var root = JsonSerializer.Deserialize<Root>(json); — the generated POCO has public auto-properties and a default constructor, which is everything the deserializer requires. With Newtonsoft.Json: var root = JsonConvert.DeserializeObject<Root>(json);

Can I generate C# 9+ records instead of classes?

The generator emits classes with auto-properties — they are the most compatible across .NET Framework, .NET Core, and .NET 5+. To convert to a record, replace public class Root { ... } with public record Root(int Id, string Name, ...); — both work with System.Text.Json once the constructor parameter names match the JSON keys (case-insensitive by default).

Why are properties generated as int instead of int??

A non-null integer in the JSON sample produces a non-nullable int because that is the most expressive type. If the field can be null in some payloads, change int to int? manually — System.Text.Json maps JSON null to a null Nullable<int> only when the property type is int?.

How are JSON arrays mapped to C#?

Arrays of objects become List<ClassName> using System.Collections.Generic. Arrays of strings become List<string>; arrays of mixed primitives fall back to List<object>. Both serializers handle List<T> directly — no extra converter required.

How are JSON keys with dashes or reserved words handled?

A JSON key like "user-id" is converted to UserId in PascalCase. Reserved C# words such as "class" or "namespace" are still legal as property identifiers when prefixed with @ (e.g. @class). Add [JsonPropertyName("user-id")] to preserve the wire-format key during serialization.

Is the JSON uploaded to your servers?

No. Conversion runs entirely in your browser via JavaScript. Open DevTools → Network and click Convert — no requests are made. JSON containing API keys, internal field names, or PII never leaves your machine.

JSON to C# Converter Online — Generate POCO Classes