search
format_align_left
JSON Formatter CSS Formatter HTML Formatter JavaScript Formatter XML Formatter SQL Formatter Exception Formatter Markdown Preview & HTML to Markdown
data_object
JSON to Excel/CSV JSON to TypeScript, C#, Go, Java, Kotlin, Python & Dart JSON ⇄ YAML / TOML Converter JSON Diff – Compare Two JSON JSON Viewer & JSONPath Tester
table_chart
Excel/CSV to JSON Excel/CSV to SQL Excel/CSV to HTML
description
Compare text Text to Hex Text to Base64 Case Converter Regex Tester Vietnamese Accent Remover & Slug Generator Word Counter Line Tools: Remove Duplicates, Sort Lines Lorem Ipsum Generator
image
Convert Image Image to Base64 Converter Image Compressor Resize & Crop Image Favicon Generator Color Palette from Image EXIF Viewer & Remover
qr_code_2
QR Code Generator QR Code Scanner VietQR Bank Transfer QR Generator Wi-Fi QR Code Generator vCard QR Code Generator (Business Card) Barcode Generator (EAN-13, Code 128, Code 39)
lock
Convert Token Convert Hash Generate Password HMAC Generator (SHA-256, SHA-512) AES Encrypt / Decrypt Online Bcrypt Hash Generator & Checker
schedule
Convert datetime Timezone Info Vietnamese Lunar Calendar Converter Date Calculator Cron Expression Parser Countdown Timer
link
Encode and Decode URLs Shorten URL URL Parser & UTM Builder HTTP Header Checker
storage
Statistics Parser Statistics Compare SQL INSERT to JSON Converter SQL Table to C# / TypeScript / Java Class
travel_explore
Create Sitemap robots.txt Generator Meta Tag Generator Open Graph Preview
terminal
Number Base Converter UUID / ULID / NanoID Generator Chmod Calculator HTTP Status Codes
palette
Color Picker
help_outline
About UsPrivacy PolicyTerms of Service
THUTOOL
search

SQL Table to C# / TypeScript / Java Class

🔒 Processed 100% in your browser – your data never leaves your device

How to generate a class from CREATE TABLE

  1. Paste one or more CREATE TABLE statements, for example from SSMS "Script Table as", SHOW CREATE TABLE in MySQL or pg_dump --schema-only.
  2. Choose C#, TypeScript or Java. The dialect is detected automatically, but you can force SQL Server, MySQL or PostgreSQL.
  3. Set the options: PascalCase/camelCase names, EF Core or JPA annotations, nullable reference types, optional properties, getters and setters.
  4. Copy the code or download the file.

Example

CREATE TABLE users (id INT IDENTITY PRIMARY KEY, user_name NVARCHAR(50) NOT NULL, email VARCHAR(255) NULL) becomes a C# class with public int Id, public string UserName and public string? Email. With annotations turned on, Id gets [Key] and [DatabaseGenerated(DatabaseGeneratedOption.Identity)], and UserName gets [Required], [MaxLength(50)] and [Column("user_name")].

Type mapping

Nullable columns become int? in C#, Integer instead of int in Java and | null in TypeScript. DECIMAL maps to decimal / BigDecimal, UNIQUEIDENTIFIER and uuid to Guid / UUID, DATETIMEOFFSET and timestamptz to DateTimeOffset / OffsetDateTime. MySQL TINYINT(1) becomes bool, and SQL Server timestamp (rowversion) becomes byte[]. PostgreSQL arrays such as text[] become arrays or List.

FAQ

Which lines are ignored? Indexes, foreign keys, CHECK constraints, table options such as ENGINE=InnoDB, and computed columns (AS (...)). The primary key is read both from the column and from CONSTRAINT ... PRIMARY KEY (...).

How is a composite primary key handled? In C# the class gets [PrimaryKey(nameof(A), nameof(B))] (EF Core 7+). In Java each key field gets @Id, and you still need an @IdClass.

Why does a non-null string end with = null!;? With nullable reference types enabled, this tells the compiler that EF Core fills the value, so you do not get warning CS8618.

Related tools

  • Statistics ParserParse SQL Server SET STATISTICS IO and TIME output into readable tables with totals for logical reads, CPU and elapsed time.
  • Statistics CompareDiscover the power and convenience of our robust SQL Statistics Parser tool for effortless query analysis. Uncover valuable insights from query execution plans, performance metrics, and resource utilization to optimize your database's efficiency. Our user-friendly interface and comprehensive parsing capabilities make it simple to compare SQL statistics with ease. Experience the strength and convenience of our SQL Statistics Parser now and take your database performance to new heights.
  • SQL INSERT to JSON ConverterConvert SQL INSERT statements to JSON and JSON back to INSERT for SQL Server, MySQL and PostgreSQL. Multi-row, N strings, NULL. Runs in your browser.
  • Regex TesterFree online regex tester: highlight matches, inspect capture and named groups, preview replace, see syntax errors. JavaScript regex, runs in your browser.
  • Image CompressorCompress JPG, PNG and WebP images in your browser. Set quality, convert to WebP/AVIF, compare sizes and download all as ZIP. No upload.
  • Vietnamese Lunar Calendar ConverterConvert solar dates to the Vietnamese lunar calendar and back (UTC+7): can chi of day, month and year, leap months and a monthly lunar calendar.
@Made by THUTOOL