JSON to C#
& TypeScript Converter
Turn one JSON sample into matching C# models and TypeScript interfaces.
Less repetitive code. More time for the interesting parts.
01 Your JSON
02 Ready to build
#nullable enable
namespace MyApp.Models;
public sealed class ApiResponse
{
[global::System.Text.Json.Serialization.JsonPropertyName("id")]
public long Id { get; set; }
[global::System.Text.Json.Serialization.JsonPropertyName("name")]
public string Name { get; set; } = string.Empty;
[global::System.Text.Json.Serialization.JsonPropertyName("email")]
public string Email { get; set; } = string.Empty;
[global::System.Text.Json.Serialization.JsonPropertyName("is_active")]
public bool IsActive { get; set; }
[global::System.Text.Json.Serialization.JsonPropertyName("address")]
public Address Address { get; set; } = new();
[global::System.Text.Json.Serialization.JsonPropertyName("projects")]
public global::System.Collections.Generic.List<ProjectsItem> Projects { get; set; } = new();
[global::System.Text.Json.Serialization.JsonPropertyName("tags")]
public global::System.Collections.Generic.List<string> Tags { get; set; } = new();
}
public sealed class Address
{
[global::System.Text.Json.Serialization.JsonPropertyName("city")]
public string City { get; set; } = string.Empty;
[global::System.Text.Json.Serialization.JsonPropertyName("country")]
public string Country { get; set; } = string.Empty;
}
public sealed class ProjectsItem
{
[global::System.Text.Json.Serialization.JsonPropertyName("name")]
public string Name { get; set; } = string.Empty;
[global::System.Text.Json.Serialization.JsonPropertyName("stars")]
public long Stars { get; set; }
}
Example ready. Paste your JSON to make it yours.
Good types start with good samples 1 note
- Inferred from this sample, not a schema. Review missing fields and nullability before use.
C# root type: ApiResponse. Dates stay strings; decimals become double.
How to convert JSON to C# and TypeScript
Code Re-shaper turns a sample API response into C# model classes for .NET and TypeScript interfaces for Angular or other TypeScript projects. Generate both from the same sample to keep their property names and inferred types consistent.
- Paste a JSON object or an array of objects, or open a local JSON file.
- Choose a root model name and C# namespace. Keep JsonPropertyName enabled when you need exact JSON field names.
- Select Generate types, then switch between C# models and TypeScript interfaces.
- Copy the code or download a .cs or .ts file. Review the inferred types before using them in your application.
A JSON-to-model example
For this JSON object, the converter maps an integer to C# long and TypeScript number, a string to string, and a boolean to bool or boolean. The C# attribute preserves the original user_id field while exposing a UserId property.
{"user_id": 7, "name": "Alex", "active": true}C# class
#nullable enable
namespace MyApp.Models;
public sealed class User
{
[global::System.Text.Json.Serialization.JsonPropertyName("user_id")]
public long UserId { get; set; }
[global::System.Text.Json.Serialization.JsonPropertyName("name")]
public string Name { get; set; } = string.Empty;
[global::System.Text.Json.Serialization.JsonPropertyName("active")]
public bool Active { get; set; }
}
TypeScript interface
export interface User {
"user_id": number;
"name": string;
"active": boolean;
}
JSON converter questions
Does this support nested JSON objects and arrays?
Yes. Nested objects become additional models. Arrays of objects are examined together, so properties missing from some objects are treated as optional. Mixed or unknown values use conservative types such as JsonElement or unknown.
Is my JSON uploaded to a server?
Conversion runs in your browser; the converter does not upload your JSON, generated code, or file contents to our API. Analytics and advertising scripts load only after separate opt-ins. Third-party scripts run on the page, so avoid confidential samples while they are enabled. Read the privacy policy and tracking controls for details.
Can I remove the C# JsonPropertyName attributes?
Yes. Clear Show JsonPropertyName to remove them from the displayed code, copies, and downloads. Without the attributes, configure JSON serialization carefully: a property such as UserId does not automatically preserve a field named user_id.
Does generated code validate my API response?
No. The converter infers types from the sample, not a complete API schema. TypeScript interfaces do not perform runtime validation. Dates remain strings, fractional numbers become double in C#, and nullability depends on the values supplied. Use representative samples and test deserialization in your application.
Is the JSON-to-C# and TypeScript converter free?
Yes. Conversion, formatting, copying, and file downloads are free and require no account. Samples are limited to 100,000 characters; oversized or excessively nested input and duplicate keys are rejected with an error.