Too Much Tools logoToo Much Tools

C# ↔ TypeScript

Generate TypeScript interfaces from C# models and C# classes from TypeScript, locally.

Local, Runs entirely in your browser, your data never leaves your device.
Loading tool…

Keep a C# API model and its TypeScript client type in sync

A backend DTO and its frontend TypeScript type tend to drift apart, especially across a solution with several models. This tool reads a pasted C# class, record or struct and emits a matching TypeScript interface, or reads a TypeScript interface or type alias and emits a C# class with get/set properties. It maps collections, dictionaries and nullable types in both directions, and runs entirely client-side so an internal DTO never leaves the browser tab.

How to use the C# ↔ TypeScript

  1. Paste a C# class into the left panel, or start from the loaded User example with a List<string> and a DateTime property.
  2. Read the generated TypeScript interface on the right, with each property mapped to string, number, boolean, an array or a Record type.
  3. Use the swap control to switch direction, paste a TypeScript interface or type alias, and get back a C# class with JsonPropertyName attributes where the casing differs.
  4. Copy the result or send it into another tool, such as the JSON generator, to produce a matching sample payload.

Nullable C# types (T?) become a TypeScript union with null, and a TypeScript optional property (name?: T) or a T | null union becomes a nullable C# property (T?) when converting the other way.

List<T>, IEnumerable<T> and similar generic collections become T[] in TypeScript; Dictionary<TKey,TValue> becomes Record<TKey, TValue>; and on the reverse conversion, TypeScript arrays and Record types map back to List<T> and Dictionary<TKey,TValue>.

Frequently asked questions

Does this handle nested C# classes or only flat models?
It parses every class, record or struct declaration it finds in the pasted code and generates one TypeScript interface per type, so a model that references another parsed type produces separate, correctly named interfaces rather than one flattened blob.
What TypeScript type does a C# DateTime become?
It maps to the TypeScript string type, since JSON has no native date type and DateTime values are serialized as ISO 8601 strings by System.Text.Json, matching what a TypeScript client actually receives over the wire.
Does converting TypeScript to C# add JsonPropertyName attributes?
Only when the PascalCase C# property name it generates differs from the original TypeScript field name, for example a camelCase TypeScript property, so the resulting class still deserializes the same JSON payload correctly.
Is my C# or TypeScript code sent to a server for this conversion?
No, the tokenizer and type-mapping logic run as plain JavaScript in your browser, so pasted model code, including internal DTO or interface names, stays local and is never uploaded anywhere.