Go to Sign up
Note: Your files never leave your device. We don't upload, transfer, or store your data.
|
|
|
|
|---|---|---|
|
|
|
A C# model class (also called a POCO — Plain Old CLR Object) is a C# class that represents a data entity with properties mapping to database columns or API fields. Model classes are the foundation of .NET application architectures including:
Entity Framework (EF Core) — Code First approach where C# classes define the database schema.
ASP.NET Core MVC / Web API — ViewModels and DTOs for request/response handling.
Domain-Driven Design (DDD) — Domain entities encapsulating business logic.
Serialization — Objects mapped to JSON, XML, or other formats for APIs and storage.
Microsoft's official C# documentation is available at Microsoft Learn C# Guide. Entity Framework documentation is at Microsoft Learn EF Core.
Excel to C# Model is a free online tool that converts spreadsheet column definitions from Excel files (.xlsx, .xls, .xlsm) into C# model class code. Each column in your spreadsheet becomes a property in the generated C# class, with automatic type inference and optional Entity Framework Data Annotations. The tool processes everything in your browser — your files are never uploaded to any server.
Namespace and Class Name — Define the namespace and class name for the generated C# file.
Access Modifiers — Choose public or internal for the class.
Property Naming Conventions — Convert column names to PascalCase (C# standard), camelCase (JSON serialization), or keep Original names.
Primary Key Support — Specify a column name to add the [Key] attribute for Entity Framework.
Data Annotations — Automatically add [Key], [Column], and [Required] attributes for Entity Framework Code First.
Nullable Reference Types — Use int?, DateTime?, decimal? for columns that may contain null values.
Automatic Type Inference — The tool infers C# types (int, string, decimal, DateTime, bool) from your data.
Indentation Control — Choose 4-space (C# default), 2-space, or tab indentation.
Built-in Table Editor — Edit cells, transpose, deduplicate, and transform data before generation.
100% Client-Side Processing — No data leaves your device.
Drag and drop an Excel file (.xlsx, .xls, or .xlsm) onto the upload area, or click to browse. Alternatively, click Enter Data to type column definitions manually.
After loading, your data appears in an editable table. Use the toolbar to modify cells, add or remove rows and columns, transpose data, remove duplicates and empty rows, change text case, or find and replace values. Toggle First Row as Header to define column names.
In the Properties panel on the right:
Namespace — Enter your project's namespace (e.g., MyApp.Models).
Class Name — Enter the class name (e.g., Product, Customer).
Access Modifier — Choose public (accessible from other projects) or internal (project-only).
Property Naming — PascalCase for standard C# properties, camelCase for JSON/JavaScript interop, or Original to keep column names as-is.
Primary Key — Enter the column name that should receive the [Key] attribute (e.g., Id).
Data Annotations — Enable to add [Key], [Column("name")], and [Required] attributes for Entity Framework.
Nullable Types — Enable to use nullable value types (int?, DateTime?) for columns with empty values.
Indent — 4 Spaces (C# convention), 2 Spaces, or Tab.
Given this Excel table with column headers:
| Id | Product Name | Price | Created At | Is Active |
|---|---|---|---|---|
| 1 | Widget A | 29.99 | 2025-01-15 | true |
With Data Annotations enabled and Primary Key set to "Id", the tool generates:
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace MyApp.Models{
[Table("Products")]
public class Product
{
[Key]
[Column("Id")]
public int Id { get; set; }
[Required]
[Column("Product Name")]
public string ProductName { get; set; }
[Column("Price")]
public decimal Price { get; set; }
[Column("Created At")]
public DateTime CreatedAt { get; set; }
[Column("Is Active")]
public bool IsActive { get; set; }
}
}
Click Convert to generate the C# code. The output appears in the Output Data panel. Click Copy to Clipboard to copy it into your .NET project. Click Restart to start over.
| Excel Data Pattern | C# Type | Nullable |
|---|---|---|
| Whole numbers (1, 42, 100) | int | int? |
| Decimals (3.14, 29.99) | decimal | decimal? |
| Text ("hello", "ABC123") | string | string (always nullable) |
| Dates (2025-01-15) | DateTime | DateTime? |
| Booleans (true, false) | bool | bool? |
Entity Framework Code First — Generate POCO entity classes from spreadsheet-defined database schemas for rapid EF Core prototyping.
API DTOs — Create Data Transfer Objects from Excel API specification documents for ASP.NET Core Web API projects.
Database Migration — Generate C# models matching legacy database tables documented in Excel spreadsheets.
ViewModels — Create ASP.NET MVC ViewModels from UI specification sheets.
Configuration Models — Generate strongly-typed configuration classes from Excel-based configuration documentation.
Unit Test Data — Create model classes for test fixtures defined in test specification spreadsheets.
Documentation — Keep data model documentation in Excel and regenerate C# code when the schema evolves.
No. All file parsing and C# code generation happens entirely in your browser using client-side JavaScript. Your files are never uploaded, transferred, or stored on any server. The tool works offline once the page has loaded.
The tool supports .xlsx (Excel 2007+), .xls (Excel 97-2003), and .xlsm (macro-enabled) files. Multi-sheet workbooks are supported — use the sheet selector to choose which sheet to convert.
Data Annotations are C# attributes (like [Key], [Column], [Required]) from the System.ComponentModel.DataAnnotations namespace. They are used by Entity Framework to configure database mapping, validation rules, and table-column relationships. Enable Data Annotations when generating EF Core entity classes. Disable them for plain POCOs, DTOs, or ViewModels that don't need database mapping.
PascalCase is the C# standard for public properties (e.g., ProductName). Use it for Entity Framework entities, domain models, and most .NET code. camelCase (e.g., productName) is common for JSON serialization in ASP.NET Core APIs (configured via JsonSerializerOptions). Original preserves your exact column names, useful when they already follow your naming convention.
Enable nullable types when your spreadsheet has empty cells in numeric or date columns. Without nullable types, the tool uses int, DateTime, etc. — which cannot be null in C#. With nullable types enabled, it generates int?, DateTime? to properly handle missing values. Note: string is always nullable in C# regardless of this setting.
The tool analyzes the data in each column to determine the most specific C# type that fits all values: whole numbers → int, decimals → decimal, dates → DateTime, booleans → bool, everything else → string. If a column contains mixed types, it falls back to string.
Yes. The generated C# code uses standard C# syntax compatible with all modern .NET versions (.NET 6+, .NET 7, .NET 8, .NET 9). The POCO classes and Data Annotations work with Entity Framework Core 6+ and ASP.NET Core.
Yes. After uploading your file, the built-in table editor lets you modify cell values, add or remove rows and columns, transpose data, remove duplicates and empty rows, change text case, and find-and-replace — all before generating the C# code.
public makes the class accessible from any other project that references the assembly. internal restricts access to within the same assembly (project). Use public for shared model libraries and internal for project-specific models that shouldn't be exposed outside the assembly.
Yes. Click the Enter Data button to open a blank editor where you can type or paste column definitions manually, then generate the C# class.