{
  "slug": "sql-schema-extractor",
  "name": "gizza-ai/sql-schema-extractor",
  "version": "0.1.0",
  "title": "SQL Schema Extractor — CREATE TABLE / ALTER to JSON or Markdown — gizza.ai",
  "description": "Parse CREATE TABLE and ALTER TABLE statements from a SQL dump into a clean table, column, and constraint model as JSON or Markdown — locally in your browser.",
  "tags": [
    "sql schema extractor",
    "ddl parser",
    "create table parser",
    "sql to json",
    "sql schema to markdown",
    "parse create table",
    "alter table parser",
    "sql ddl to json",
    "extract database schema"
  ],
  "category": "data",
  "urls": {
    "page": "https://gizza.ai/tools/sql-schema-extractor/",
    "markdown": "https://gizza.ai/tools/sql-schema-extractor/index.md",
    "descriptor": "https://gizza.ai/tools/sql-schema-extractor/tool.json",
    "deep_link_example": "https://gizza.ai/tools/sql-schema-extractor/?sql=CREATE%20TABLE%20users%20%28%0A%20%20id%20INT%20PRIMARY%20KEY%20AUTO_INCREMENT%2C%0A%20%20email%20VARCHAR%28255%29%20NOT%20NULL%20UNIQUE%2C%0A%20%20age%20INT%20DEFAULT%200%20CHECK%20%28age%20%3E%3D%200%29%0A%29%3B&output=json&dialect=auto&apply_alter=true&include_indexes=true"
  },
  "cli": "gizza tool sql-schema-extractor \"CREATE TABLE users (\n  id INT PRIMARY KEY AUTO_INCREMENT,\n  email VARCHAR(255) NOT NULL UNIQUE,\n  age INT DEFAULT 0 CHECK (age >= 0)\n);\"",
  "tool": {
    "description": "Parse the DDL out of a SQL dump — CREATE TABLE, ALTER TABLE, and CREATE INDEX statements — into a clean, structured schema model. For each table it extracts columns (name, data type with params like VARCHAR(255)/DECIMAL(10,2), nullability, default value, auto-increment/serial/identity), the primary key (inline or table-level, including composite), foreign keys (columns, referenced table/columns, ON DELETE/UPDATE actions), unique constraints, CHECK constraints, and indexes. ALTER TABLE ... ADD statements are folded onto their target table so the model reflects the final schema. It is a lenient parser, not a SQL engine: comments and non-DDL statements (INSERT, SELECT, DROP, …) are skipped, and nothing is executed. Output as a JSON model or a Markdown schema doc. Supports MySQL, PostgreSQL, SQLite, MSSQL and generic dialects (identifier quoting normalized). It never emits INSERT rows.",
    "parameters": {
      "additionalProperties": false,
      "properties": {
        "apply_alter": {
          "default": true,
          "description": "Fold ALTER TABLE ... ADD [COLUMN|CONSTRAINT|PRIMARY KEY|FOREIGN KEY|UNIQUE|CHECK|INDEX] statements onto their target table so the model reflects the final schema. When false, ALTER statements are ignored and only CREATE TABLE is used. Default true.",
          "type": "boolean"
        },
        "dialect": {
          "default": "auto",
          "description": "SQL dialect hint. Identifiers are normalized for every dialect (backticks, \"double quotes\" and [brackets] are stripped); this mainly controls whether '#' starts a line comment (mysql/auto) and is echoed back in the output. Default auto.",
          "enum": [
            "auto",
            "mysql",
            "postgres",
            "sqlite",
            "mssql",
            "generic"
          ],
          "type": "string"
        },
        "include_indexes": {
          "default": true,
          "description": "Include index definitions (table-level KEY/INDEX, plus CREATE INDEX / CREATE UNIQUE INDEX) in the model. When false, indexes are omitted (the 'indexes' array is dropped from JSON and the index bullets from Markdown). Default true.",
          "type": "boolean"
        },
        "output": {
          "default": "json",
          "description": "Output format. 'json' (default) emits a structured model {dialect, table_count, column_count, tables:[{name, columns, primary_key, foreign_keys, unique_constraints, checks, indexes}]}. 'markdown' emits one section per table with a column table plus bullet lists of the constraints. Default json.",
          "enum": [
            "json",
            "markdown"
          ],
          "type": "string"
        },
        "sql": {
          "description": "The SQL dump / DDL text to parse. Include one or more CREATE TABLE (and optionally ALTER TABLE / CREATE INDEX) statements — e.g. \"CREATE TABLE users (id INT PRIMARY KEY, email VARCHAR(255) NOT NULL UNIQUE);\". Comments (-- , #, /* */), INSERT/SELECT and other non-DDL statements are ignored. Nothing is executed.",
          "type": "string"
        }
      },
      "required": [
        "sql"
      ],
      "type": "object"
    }
  }
}