Generate classes from CSV

Generate C# model or stub classes from CSV file. You can select the property naming convention (Pascal, Camel or Original) and whether or not to generate a class map for the CsvHelper library. The generator is smart enough to detect data types for the output properties of the C# class. It can even work with just the header row of a CSV file.

Converted on ToolSlick's server. Your input and its output are not stored.

Paste CSV content below
Generated Classes

Settings

How the input is converted. Each is explained below.

The name of the generated Class

History

  • 2018-07-08Ability to generate class from just CSV Header
  • 2018-03-07Support for semi-colon delimiters
  • 2018-03-07Delimiter & First Row is Header Parameters
  • 2017-12-09Tool Launched

Settings explained

First Row Is Header
If selected, the first row of the CSV is the header, and the properties are named after its fields. If not, they are named Column1, Column2, Column3 and so on, and the first row is read as data.
First Row is Header On
public class Model
{
    public string Name { get; set; }
    public string Department { get; set; }
    public string Manager { get; set; }
    public int Salary { get; set; }
}
First Row is Header Off
public class Model
{
    public string Column1 { get; set; }
    public string Column2 { get; set; }
    public string Column3 { get; set; }
    public string Column4 { get; set; }
}
Delimiter
The delimiter of the input CSV: comma, tab, space, pipe or semi-colon. Auto Detect works in most cases, but in a really small CSV whose delimiter also occurs in its values, it may pick the wrong one; then choose it here.
Class Name
The name of the generated Class.
Language
The language for which the classes are generated. C# is the only one offered.
Generate Class Map
If selected, a CsvHelper compliant class map is generated.
Generate Class Map On
public class Person
{
    public string FullName { get; set; }
    public int age { get; set; }
}

public class PersonClassMap : ClassMap<Person>
{
    public PersonClassMap()
    {
        Map(m => m.FullName).Name("Full Name");
        Map(m => m.age).Name("age");
    }
}
Generate Class Map Off
public class Person
{
    public string FullName { get; set; }
    public int age { get; set; }
}
Property Naming Strategy
Choose the naming strategy of the generated properties. The available options are:
Cleanse Only
public class Person
{
    public string FullName { get; set; }

    public int age { get; set; }
}
Pascal Case
public class Person
{
    public string FullName { get; set; }

    public int Age { get; set; }
}
Camel Case
public class Person
{
    public string fullName { get; set; }

    public int age { get; set; }
}

Background

CSV is an old & very popular format for storing tabular data. It has been used in the desktop as well as mainframe. It is a simple & compact format that works really well for tabular data and so is still in use today.