Go to Sign up
Note: Your files never leave your device. We don't upload, transfer, or store your data.
|
|
|
|
|---|---|---|
|
|
|
When building .NET applications with Entity Framework, ASP.NET Web API, or any data-driven architecture, you need C# classes (models, entities, DTOs) that mirror your data schema. Writing these classes by hand is repetitive — each column becomes a property with the correct type, and columns headers must be converted to valid C# identifiers.
The CSV to C# Model Converter on A.Tools automates this: upload a CSV file, and the tool produces a complete C# class with auto-typed properties, optional Data Annotations, and configurable naming conventions. Paste the output directly into your .cs file.
All processing runs locally in your browser. No data leaves your device.
The tool examines the data in each column and infers the correct C# type:
| Data Pattern | C# Type | Nullable Variant |
|---|---|---|
"Alice", "NYC" | string | string (reference type, always nullable) |
30, -5, 0 | int | int? |
3.14, 99.99 | double | double? |
true, false | bool | bool? |
2026-05-07, 01/15/2026 | DateTime | DateTime? |
12.50, 0.00 (currency) | decimal | decimal? |
If a column has mixed types or the tool cannot determine a specific type, it defaults to string.
Namespace — Wrap the class in a namespace (e.g., MyApp.Models). Leave empty for no namespace wrapper.
Class Name — Set the class name (e.g., Product, UserDto). Defaults to MyClass if empty.
Access Modifier — Choose public (accessible from any assembly) or internal (accessible only within the same assembly).
| Convention | CSV Header | C# Property |
|---|---|---|
| PascalCase | first_name | FirstName |
| camelCase | first_name | firstName |
| Original | first_name | first_name |
PascalCase is the C# convention for public properties. camelCase is common for JSON serialization with System.Text.Json. Original preserves the CSV header exactly.
Enable Data Annotations to add attributes from System.ComponentModel.DataAnnotations:
[Column("first_name")] — Maps the property to the original CSV/database column name.
[Required] — Marks the property as non-nullable for validation.
[Key] — Marks the property as a primary key (when Primary Key is configured).
[Key]
[Column("id")]
public int Id { get; set; }
[Required]
[Column("first_name")]
public string FirstName { get; set; }
Enter a column name in the Primary Key field. The tool adds a [Key] attribute to the matching property, signaling Entity Framework that this is the primary key column.
Enable Nullable Types to generate nullable value types:
Without nullable:
public int Age { get; set; }
public DateTime CreatedAt { get; set; }
With nullable:
public int? Age { get; set; }
public DateTime? CreatedAt { get; set; }
This is essential when:
Your CSV has empty cells in numeric or date columns.
You are mapping to database columns that allow NULL.
You are using C# 8+ nullable reference types (#nullable enable).
Choose between 4 spaces (C# default), 2 spaces, or tab indentation.
Edit your data in-browser before converting:
Undo / Redo — Full edit history.
Add / Delete Rows & Columns — Expand or trim the table.
Transpose — Swap rows and columns.
Delete Empty — Remove empty rows and columns.
Deduplicate — Remove duplicate rows.
ABC / abc / Abc — Batch case conversion.
Find & Replace — With regex support.
First Row as Header — Column headers become C# property names.
All processing runs client-side via the browser File API. Files are never uploaded, transmitted, or stored. Safe for database schema metadata, proprietary data models, and production column definitions.
Upload a .csv or .tsv file by dragging it onto the upload area, or click to browse. Alternatively, click Enter Data to type or paste data directly.
Use the toolbar to refine your data:
Add, insert, or delete rows and columns.
Transpose the table.
Remove empty rows/columns or duplicate rows.
Change text case of headers.
Find and replace values (supports regex).
Toggle First Row as Header to define column names.
In the Properties panel:
| Option | What to Set |
|---|---|
| Namespace | e.g., MyApp.Models or MyApp.Data.Entities |
| Class Name | e.g., Product, UserDto, OrderViewModel |
| Access Modifier | public (default) or internal |
| Property Naming | PascalCase (C# convention) or camelCase (JSON) |
| Primary Key | Column name to receive [Key] attribute |
| Data Annotations | On to add [Column], [Required], [Key] |
| Nullable Types | On if columns may contain null/empty values |
| Indent | 4 spaces (default), 2 spaces, or tab |
Click Convert. The C# class code appears in the Output Data panel.
Click Copy to Clipboard and paste into a new .cs file in your .NET project. Add the required using statements:
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
Input CSV:
id,product_name,category,price,stock_count,is_active,created_at
1,Widget A,Hardware,12.99,145,true,2026-01-15
2,Widget B,Hardware,8.50,0,false,2026-02-20
3,Gadget X,Electronics,45.00,23,true,2026-03-10
Settings: Namespace: MyApp.Data.Entities, Class: Product, PascalCase, Primary Key: id, Data Annotations: On, Nullable: On, Indent: 4 Spaces
Output:
namespace MyApp.Data.Entities
{
public class Product
{
[Key]
[Column("id")]
public int? Id { get; set; }
[Required]
[Column("product_name")]
public string ProductName { get; set; }
[Column("category")]
public string Category { get; set; }
[Column("price")]
public double? Price { get; set; }
[Column("stock_count")]
public int? StockCount { get; set; }
[Column("is_active")]
public bool? IsActive { get; set; }
[Column("created_at")]
public DateTime? CreatedAt { get; set; }
}
}
Input CSV:
userId,userName,email,avatarUrl,lastLogin
101,Alice,[email protected],https://img.example.com/alice.png,2026-05-07
102,Bob,[email protected],,2026-05-06
Settings: Namespace: MyApp.API.DTOs, Class: UserDto, camelCase, Data Annotations: Off, Nullable: On
Output:
namespace MyApp.API.DTOs
{
public class UserDto
{
public int? userId { get; set; }
public string userName { get; set; }
public string email { get; set; }
public string avatarUrl { get; set; }
public DateTime? lastLogin { get; set; }
}
}
Input CSV:
name,email,role
Alice,[email protected],Admin
Bob,[email protected],Editor
Settings: Class: User, PascalCase, No namespace, No annotations, No nullable
Output:
public class User
{
public string Name { get; set; }
public string Email { get; set; }
public string Role { get; set; }
}
| Term | Purpose | Example |
|---|---|---|
| Entity | Maps to a database table (EF Core) | Product, Order |
| DTO | Data Transfer Object for API input/output | ProductDto, OrderResponse |
| ViewModel | Shape data for a specific view/page | ProductListViewModel |
| POCO | Plain Old CLR Object — simple class with properties | Any of the above |
This tool generates POCOs that can serve as any of these, depending on how you configure the options.
The tool generates C# auto-implemented properties:
public string Name { get; set; }This is the standard C# shorthand for a property with a backing field. The { get; set; } syntax was introduced in C# 3.0 and is the idiomatic way to define data classes. See Microsoft Learn — Properties.
Entity Framework uses Data Annotations as convention-based configuration:
[Key] — Specifies the primary key.
[Column("db_column_name")] — Maps a property to a specific database column name.
[Required] — Makes the column NOT NULL in the database and adds validation.
These attributes come from System.ComponentModel.DataAnnotations and System.ComponentModel.DataAnnotations.Schema.
Enable nullable types when:
Your CSV data has empty cells in numeric, date, or boolean columns.
You are generating models for database tables with nullable columns.
Your project uses C# 8+ nullable reference types (#nullable enable).
When using the generated class with EF Core:
Properties named Id or <ClassName>Id are automatically detected as primary keys.
The [Key] attribute overrides this convention.
PascalCase property names are converted to snake_case or other conventions by EF's column naming strategy.
No. All file processing happens entirely in your browser using JavaScript. Your CSV data is never uploaded, transferred, or stored on any server.
The tool analyzes the actual data values in each CSV column. If all values are whole numbers, it uses int. If values contain decimal points, it uses double. If values match date patterns, it uses DateTime. Boolean values (true/false) map to bool. Everything else defaults to string.
Data Annotations are C# attributes from System.ComponentModel.DataAnnotations that add metadata to class properties. The tool generates [Key] for primary keys, [Column("name")] for column mapping, and [Required] for non-nullable validation. These are used by Entity Framework, ASP.NET Model Validation, and API formatters.
Enter the exact name of a CSV column. The tool adds a [Key] attribute to the corresponding C# property, which tells Entity Framework that this property is the primary key for the database table.
PascalCase capitalizes the first letter of each word: FirstName, StockCount. This is the C# convention for public properties and is the default for Entity Framework. camelCase lowercases the first word: firstName, stockCount. This is common for JSON serialization with System.Text.Json and JavaScript interop.
When enabled, value types (int, double, DateTime, bool) are generated as nullable (int?, double?, DateTime?, bool?). This allows the property to hold a null value, which is necessary when your CSV has empty cells or your database columns allow NULL.
The tool accepts .csv (comma-separated values) and .tsv (tab-separated values) files. You can also enter data manually through the built-in table editor.
Type inference uses only the first row of data to determine column types. The class definition itself depends only on column headers (one property per column), so there is no practical limit on the number of data rows.