Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>C# to Dart ConverterNew to Visual Studio Code? Get it now.
C# to Dart Converter

C# to Dart Converter

Rajan Gurung

|
18 installs
| (1) | Free
Convert C# model classes to Dart with json_annotation support
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

C# to Dart Converter

Convert C# model classes to Dart with json_annotation support.

Features

  • Converts C# model classes to Dart following json_annotation package patterns
  • Generates clean, modern Dart code with proper null safety
  • Handles nested classes and complex type mappings
  • Excludes FluentValidation validators automatically
  • Smart context menu that appears only when C# code is detected
  • Single file output with all related classes

Usage

  1. Create a new .dart file (e.g., models.dart)
  2. Paste your C# model code into the file
  3. Right-click in the editor
  4. Select "Convert C# to Dart"
  5. Your C# code is instantly converted to Dart!

Examples

1. Simple Model

Input (C#):

public class User
{
    public int Id { get; set; }
    public string Name { get; set; }
    public bool IsAdmin { get; set; }
}

Output (Dart):

import 'package:json_annotation/json_annotation.dart';

part 'user.g.dart';

@JsonSerializable()
class User {
  User({
    required this.id,
    required this.name,
    required this.isAdmin,
  });

  int id;
  String name;
  bool isAdmin;

  factory User.fromJson(Map<String, dynamic> json) =>
      _$UserFromJson(json);

  Map<String, dynamic> toJson() => _$UserToJson(this);
}

2. Deeply Nested Model

Input (C#):

public class Company
{
    public string CompanyName { get; set; }
    public Department[] Departments { get; set; }

    public class Department
    {
        public string DeptName { get; set; }
        public Employee[] Employees { get; set; }

        public class Employee
        {
            public int EmpId { get; set; }
            public string EmpName { get; set; }
        }
    }
}

Output (Dart):

import 'package:json_annotation/json_annotation.dart';

part 'company.g.dart';

@JsonSerializable()
class Company {
  Company({
    required this.companyName,
    required this.departments,
  });

  String companyName;
  List<Department> departments;

  factory Company.fromJson(Map<String, dynamic> json) =>
      _$CompanyFromJson(json);
  Map<String, dynamic> toJson() => _$CompanyToJson(this);
}

@JsonSerializable()
class Department {
  Department({
    required this.deptName,
    required this.employees,
  });

  String deptName;
  List<Employee> employees;

  factory Department.fromJson(Map<String, dynamic> json) =>
      _$DepartmentFromJson(json);
  Map<String, dynamic> toJson() => _$DepartmentToJson(this);
}

@JsonSerializable()
class Employee {
  Employee({
    required this.empId,
    required this.empName,
  });

  int empId;
  String empName;

  factory Employee.fromJson(Map<String, dynamic> json) =>
      _$EmployeeFromJson(json);

  Map<String, dynamic> toJson() => _$EmployeeToJson(this);
}
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft