T-SQL to Java and C# Converter: SQL Table to Class

Paste a MySQL, PostgreSQL or T-SQL CREATE TABLE and get the model as Java, C#, TypeScript, Go or Rust code.

CREATE TABLE to a C#, Java or TypeScript class: type mapping

The tool reads a CREATE TABLE statement, extracts the table name and each column (name, type, NOT NULL), then writes the matching model: a C# or Java class, a TypeScript interface, a Go or Rust struct, or a sample record in JSON or XML. Names are converted to PascalCase or camelCase and columns without NOT NULL become optional.

How the table is read

Comments are removed, the name follows CREATE TABLE (double quotes, backticks or T-SQL brackets accepted, schema prefix such as dbo. or public. ignored), then the content between parentheses is split on commas, except those inside DECIMAL(10, 2). PRIMARY KEY, FOREIGN KEY, CONSTRAINT, UNIQUE and INDEX lines are skipped. A column is non-nullable if it carries NOT NULL or PRIMARY KEY.

Example

The sample Users table (user_id INT PRIMARY KEY, username VARCHAR(50) NOT NULL, email VARCHAR(100), is_active BOOLEAN, created_at DATETIME, balance DECIMAL(10, 2), bio TEXT) gives in C#:
public int UserId { get; set; }
public string Username { get; set; }
public bool? IsActive { get; set; }
public DateTime? CreatedAt { get; set; }
public decimal? Balance { get; set; }
and in TypeScript userId: number; email?: string; createdAt?: Date; balance?: number;.

Known limits

  • A type missing from the mapping (BLOB, BYTEA, ENUM…) becomes a string; UUID gives Guid in C# and UUID in Java, a string in the other languages.
  • Only one table is handled; no annotations, relations or Java getters (a comment marks their place).
  • Go keeps non-nullable types; Rust uses Option<T> for optional columns, without derives or imports.

Review the generated code before using it. To reformat a query, use the SQL formatter instead.

Frequently Asked Questions

Which C# type matches a SQL DECIMAL or DATETIME?

The tool maps DECIMAL to decimal, DATETIME and DATE to DateTime, BOOLEAN and BIT to bool, and VARCHAR, CHAR and TEXT to string. A column without NOT NULL gets a question mark (decimal?, DateTime?), except string, which already accepts null. In Java the same columns become BigDecimal, LocalDateTime, Boolean and String.

What type does a BIGINT column get?

BIGINT becomes long in C#, Long in Java and i64 in Rust, which avoids overflow beyond 2,147,483,647. SMALLINT gives short, Short and i16, TINYINT byte, Byte and i8. The tool first looks for the exact type, then for the longest known name contained in the type, so NVARCHAR is read as VARCHAR. In TypeScript every integer stays number.

Does the tool read SQL Server scripts?

Yes: square brackets are accepted around table, column and type names ([dbo].[Users], [Id] [bigint]), and the schema prefix is ignored, so [dbo].[Users] gives the class Users and public.orders the class Orders. CONSTRAINT lines, such as a CLUSTERED primary key, are skipped.

How are the generated properties named?

snake_case column names become PascalCase for C# and Go (user_id becomes UserId) and camelCase for Java and TypeScript (userId). Rust, JSON and XML keep the original name. Go adds a json tag with the original column name.

Is this tool really free?

Yes, all tools on Kristools are 100% free and accessible without registration.

Is my data protected?

Yes. All processing is performed directly and securely inside your browser. No personal data is sent to our servers.