Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit

- fixed #107 <custom-body> inside enum doesn't stay after regenarate;
- fixed #153 Make "bin" directory configurable;

Git stats


Failed to load latest commit information.
Latest commit message
Commit time
May 4, 2023 20:51
June 25, 2016 12:34
August 8, 2019 11:48
May 4, 2023 20:49
November 26, 2022 01:23


Single-class-per-file C# to TypeScript generator

Buy me a coffee

Build status


How to get

How to build

Running the following commands will create NuGet packages in the root directory (in this example for version 3.0.0):

.\update-version.ps1 3.0.0

How to use

  1. Add the TypeGen NuGet package to your project. The dotnet-typegen package can be used for a .NET tool.

  2. Select the types to export to TypeScript:

// using attributes

public class ProductDto
    public decimal Price { get; set; }
    public string[] Tags { get; set; }

// or using a specification file (a "generation spec") created anywhere in your project

public class MyGenerationSpec : GenerationSpec
    public MyGenerationSpec()
  1. If you're using a generation spec, create a file named tgconfig.json directly in your project folder with the following content:
  "generationSpecs": ["MyGenerationSpec"]
  1. Build your project and type TypeGen generate or TypeGen -p "MyProjectName" generate (depending on the current working directory of the PM Console) into the Package Manager Console (you might need to restart Visual Studio), or dotnet typegen generate in the system console to use the .NET tool.

After completing the above, a single TypeScript file (named product-dto.ts) should be generated in your project's root directory with the following content:

export class ProductDto {
    price: number;
    tags: string[];


The features include (full list of features is available in the documentation):

  • generating TypeScript classes, interfaces and enums (single class per file)
  • generating barrel (index) files
  • support for collections
  • support for generic types
  • support for inheritance
  • customizable translation of naming conventions