Why Convert SQL Schema to JSON Schema?
When your database schema is the source of truth, manually writing JSON Schema validators or TypeScript interfaces creates drift — the code diverges from the DB over time. Starting from the CREATE TABLE statement and generating the JSON Schema or TypeScript gives you a validated starting point that matches the actual database structure.
What quicktype.io and transform.tools Don't Do
quicktype.io converts JSON data or JSON Schema to strongly-typed code — it works from the JSON side, not the SQL side. transform.tools handles format conversion between serialization formats (JSON→YAML, etc.) but doesn't parse SQL DDL. There is no widely-used free tool that takes a CREATE TABLE statement and outputs a JSON Schema or TypeScript interface — which is exactly this tool's gap.
SQL Type Mapping Reference
INT / INTEGER / BIGINT → integer (JSON Schema), number (TypeScript)
FLOAT / DECIMAL / NUMERIC → number
VARCHAR / TEXT / CHAR → string
BOOLEAN / BOOL / TINYINT(1) → boolean
DATE / DATETIME / TIMESTAMP → string with format: date-time
JSON / JSONB → object
UUID / UNIQUEIDENTIFIER → string with format: uuid
Handling NULL and NOT NULL
Columns declared NOT NULL are added to the JSON Schema's required array. NULLable columns get a ? optional modifier in TypeScript output. Primary key columns are always treated as required.
Frequently Asked Questions
Can I convert a MySQL CREATE TABLE to a TypeScript interface?
Yes. Paste the CREATE TABLE statement, select "TypeScript Interface" from the output format dropdown, and click Convert. MySQL types (INT, VARCHAR, TINYINT(1), etc.) are mapped to appropriate TypeScript primitive types.
What is JSON Schema draft-07?
JSON Schema draft-07 is widely supported by validation libraries like Ajv, jsonschema (Python), and NJsonSchema (.NET). It includes $schema, title, type, properties, required, and format keywords. The output of this tool is valid draft-07 JSON Schema.
Does it handle multiple CREATE TABLE statements?
Yes. Paste multiple CREATE TABLE statements separated by semicolons and the tool will parse all of them, outputting a JSON array of schemas (one per table).
What SQL dialects are supported?
MySQL (INT, VARCHAR, TINYINT(1)/BOOLEAN, JSON, AUTO_INCREMENT), PostgreSQL (SERIAL, BOOLEAN, JSONB, UUID, TIMESTAMPTZ), SQLite (INTEGER, REAL, TEXT, BLOB), and SQL Server (NVARCHAR, UNIQUEIDENTIFIER, DATETIME2, BIT, MONEY).