Menu
100% Client-Side • In-Browser Execution • Privacy Guaranteed

SQL to TypeScript & Types Converter Online (Pydantic, Go, Rust, JSON Schema)

Convert SQL CREATE TABLE statements to TypeScript interfaces, Python Pydantic models, Go structs, Rust structs, and JSON Schema online for PostgreSQL, MySQL, SQLite, and SQL Server.

Convert database CREATE TABLE DDL statements into typed programming language models, API schemas, and interface definitions in seconds. For a complete type mapping breakdown and dialect nuances, read our companion guide How to Convert SQL CREATE TABLE to TypeScript, Pydantic, and Go Types. Paste your SQL schema or DDL script from PostgreSQL, MySQL, SQLite, SQL Server, or Oracle; the tool automatically extracts table names, column data types, nullability rules, primary keys, and comments, converting them into clean, idiomatic TypeScript interfaces, Python Pydantic v2 models, Go structs with JSON and DB tags, Rust structs, JSON Schema, or Java Records. All processing executes 100% locally inside your web browser—your schema structure never leaves your device.

The SQL to Types converter requires JavaScript to run in your browser. Please enable JavaScript to use this tool.

How the SQL to Types Converter Works

Modern application development requires syncing database table schemas with strongly typed backend and frontend data structures. Manually transcribing SQL columns into TypeScript types, Python Pydantic models, or Go structs is tedious, prone to human error, and easily leads to drift when schemas change.

This tool inspects SQL CREATE TABLE statements in real time, parses the AST (Abstract Syntax Tree) representation of table objects, and translates database types to their exact target language equivalents:

  1. Table Object Extraction: Identifies single or multi-table DDL definitions, stripping database-specific table options such as MySQL’s ENGINE=InnoDB or PostgreSQL tablespace allocations.
  2. Column Inspection: Distinguishes column definitions from table-level constraints (PRIMARY KEY (...), CONSTRAINT fk_..., indexes).
  3. Data Type Normalization: Maps SQL primitives (integers, floating-point decimals, fixed-point currencies, timestamps, JSON/JSONB, UUIDs, enums, byte arrays) to standard language type systems.
  4. Nullability & Optionality: Accurately flags nullable fields (NULL without PRIMARY KEY) as optional or unioned with null/None/pointers.
  5. Multi-Dialect DDL Parsing: Works out-of-the-box with schemas dumped from PostgreSQL (pg_dump), MySQL (mysqldump), SQLite, SQL Server, and Oracle.

SQL Data Type Mapping Reference

The following table summarizes how standard SQL data types across PostgreSQL, MySQL, and SQLite map to target programming language types:

SQL Data Type TypeScript Python (Pydantic / Dataclass) Go Struct Rust Struct JSON Schema
INT, INTEGER, SERIAL number int int / int32 i32 {"type": "integer"}
BIGINT, BIGSERIAL, INT8 number int int64 i64 {"type": "integer"}
DECIMAL(p, s), NUMERIC number Decimal float64 f64 {"type": "number"}
FLOAT, DOUBLE, REAL number float float64 f64 {"type": "number"}
VARCHAR, CHAR, TEXT string str string String {"type": "string"}
BOOLEAN, BOOL, TINYINT(1) boolean bool bool bool {"type": "boolean"}
TIMESTAMP, TIMESTAMPTZ, DATETIME string / Date datetime time.Time DateTime<Utc> {"type": "string", "format": "date-time"}
DATE string / Date date time.Time DateTime<Utc> {"type": "string", "format": "date"}
JSON, JSONB Record<string, unknown> dict[str, Any] map[string]any serde_json::Value {"type": "object"}
UUID, UNIQUEIDENTIFIER string UUID string Uuid {"type": "string", "format": "uuid"}
ENUM('draft', 'published') 'draft' | 'published' str string String {"type": "string", "enum": [...]}
TEXT[], INT[] (Postgres array) string[] / number[] list[str] / list[int] []string / []int Vec<String> / Vec<i32> {"type": "array"}

Frequently Asked Questions

Does this tool send database schemas to a remote server?

No. All DDL parsing, tokenizing, and model code generation runs 100% client-side in your web browser. No table names, column structures, or SQL fragments are uploaded or logged to any remote server.

Can I convert multiple SQL tables at the same time?

Yes. You can paste an entire SQL schema script containing dozens of CREATE TABLE blocks. The tool generates all corresponding TypeScript interfaces, Pydantic models, or Go structs sequentially in the output window.

How does the converter handle nullable columns?

In SQL, columns without a NOT NULL clause (and not designated as PRIMARY KEY) are nullable by default. For TypeScript, you can configure whether nullable fields render as col: type | null, optional properties col?: type, or both col?: type | null. For Python Pydantic, nullable fields default to col: type | None = None. For Go, nullable fields are rendered as pointers (e.g. *string, *int64) to safely represent SQL NULL.

How are PostgreSQL JSONB and MySQL JSON columns converted?

JSON and JSONB columns are mapped to typed object containers: Record<string, unknown> in TypeScript, dict[str, Any] in Python, map[string]any in Go, and serde_json::Value in Rust.

Can I run the table schema immediately in the browser?

Yes. Click the Open DDL in SQLite Playground button below the output window to instantly transfer your CREATE TABLE statements into the SQLite Playground and execute queries against an in-memory database.