npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cs2ts-sf9

v1.0.4

Published

A powerful CLI tool that converts C# model classes to TypeScript interfaces with full support for inheritance, class references, and intelligent naming conventions.

Readme

CS2TS Simplify9 - C# to TypeScript Converter

npm version License: MIT

A powerful CLI tool that converts C# model classes to TypeScript interfaces with full support for inheritance, class references, and intelligent naming conventions.

🚀 Features

  • 🔄 Complete Type Conversion: Converts C# classes and interfaces to TypeScript interfaces
  • 📦 Inheritance Support: Handles class inheritance (Admin : UserAdmin extends User)
  • 🔗 Cross-File References: Automatically generates imports for type dependencies
  • 📝 Smart Naming: Converts PascalCase to camelCase with intelligent acronym handling
  • 📁 Same-File Grouping: Multiple C# types in one file generate one TypeScript file
  • 🧠 Registry-Aware: Distinguishes between primitive types and custom classes
  • 📋 Collection Support: List<T>, IEnumerable<T>, ICollection<T>T[]

📦 Installation

Global Installation

npm install -g cs2ts-sf9

Local Installation

npm install --save-dev cs2ts-sf9

🛠 Usage

CLI Command

cs2ts-sf9 convert -s <source-directory> -o <output-directory>

Options

  • -s, --source <path>: Source directory containing C# files (default: ./)
  • -o, --out <path>: Output directory for TypeScript files (default: ./types)
  • -h, --help: Display help information
  • -V, --version: Display version number

Examples

Basic conversion:

cs2ts-sf9 convert -s ./Models -o ./src/types

Using default directories:

cs2ts-sf9 convert

From package.json script:

{
  "scripts": {
    "generate-types": "cs2ts-sf9 convert -s ./backend/Models -o ./frontend/src/types"
  }
}

📝 Input/Output Examples

C# Input Files

Models/User.cs

public class User
{
    public Guid Id { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public string Email { get; set; }
    public DateTime CreatedDate { get; set; }
    public bool IsActive { get; set; }
}

public interface IRepository
{
    Guid Id { get; set; }
    void Save();
}

public class Admin : User
{
    public string Role { get; set; }
    public List<string> Permissions { get; set; }
}

Models/Product.cs

public class Product
{
    public Guid Id { get; set; }
    public string Name { get; set; }
    public decimal Price { get; set; }
    public Item MainItem { get; set; }
    public List<Item> RelatedItems { get; set; }
    public User CreatedBy { get; set; }
}

public class Item
{
    public Guid Id { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
}

TypeScript Output Files

types/User.ts

export interface User {
  id: string;
  firstName: string;
  lastName: string;
  email: string;
  createdDate: string;
  isActive: boolean;
}

export interface IRepository {
  id: string;
}

export interface Admin extends User {
  role: string;
  permissions: string[];
}

types/Product.ts

import { User } from "./User";

export interface Product {
  id: string;
  name: string;
  price: number;
  mainItem: Item;
  relatedItems: Item[];
  createdBy: User;
}

export interface Item {
  id: string;
  name: string;
  description: string;
}

🧠 Intelligent Features

Smart Naming Conversion

CS2TS intelligently converts C# PascalCase properties to TypeScript camelCase:

| C# Property | TypeScript Property | Notes | | ---------------- | ------------------- | ---------------------------- | | FirstName | firstName | Standard conversion | | ID | id | Acronym handling | | URL | url | Acronym handling | | XMLData | xmlData | Leading acronym + PascalCase | | IsHTTPSEnabled | isHTTPSEnabled | Mixed case handling |

Supported Acronyms: ID, URL, URI, XML, HTML, HTTP, HTTPS, API, JSON, SQL, UI, UX

Type Mapping

| C# Type | TypeScript Type | Notes | | --------------------------------------------- | ------------------ | -------------------------- | | int, float, double, decimal | number | All numeric types | | string | string | Direct mapping | | bool | boolean | Boolean conversion | | DateTime, Guid | string | Serialization assumption | | List<T>, IEnumerable<T>, ICollection<T> | T[] | Generic collections | | CustomClass | CustomClass | Preserved for known types | | int?, string? | number, string | Nullable types (? removed) |

Import Generation

  • Cross-file references: Automatically generates imports when types reference classes from other files
  • Same-file optimization: Types in the same C# file don't import each other
  • Relative paths: Uses relative imports (./User, ./Models)
  • Sorted imports: Alphabetically ordered for consistency

🏗 Architecture

CS2TS uses a two-pass parsing architecture:

  1. First Pass: Scans all C# files to build registries of classes and interfaces
  2. Second Pass: Processes inheritance relationships and resolves type dependencies

Supported C# Features

  • ✅ Public classes and interfaces
  • ✅ Class inheritance (class Admin : User)
  • ✅ Interface inheritance (interface IUserRepo : IRepository)
  • ✅ Auto-properties with { get; set; } syntax
  • ✅ Generic collections (List<T>, IEnumerable<T>)
  • ✅ Nullable types (string?, int?)
  • ✅ Multiple types per file

Limitations

  • ❌ Method signatures (interfaces only extract properties)
  • ❌ Custom property accessors (only auto-properties)
  • ❌ Attributes/annotations
  • ❌ Generic type constraints
  • ❌ Nested classes

🔧 Configuration

Currently, CS2TS works with zero configuration. Future versions may include:

  • Custom type mappings
  • Naming convention options
  • Output format preferences
  • Include/exclude patterns

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development Setup

git clone https://github.com/fawzi-shiyyab19/cs2ts-sf9.git
cd cs2ts-sf9
npm install
npm run build

Testing

# Run the built CLI
npm run build
node dist/index.js convert -s ./test-models -o ./test-output

# Development mode
npm run start -- convert -s ./test-models -o ./test-output

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🐛 Issues

If you encounter any issues or have feature requests, please create an issue on GitHub.

📈 Changelog

v1.0.0

  • Initial release
  • C# to TypeScript conversion
  • Inheritance support
  • Automatic import generation
  • Smart naming conventions
  • Same-file type grouping

Made with ❤️ for developers working with C# and TypeScript