{"id":43891,"library":"sql-ddl-to-json-schema","title":"sql-ddl-to-json-schema","description":"Parse SQL DDL statements and convert them to JSON Schema documents and a compact JSON format. Version 6.0.0 supports Node.js >=16 <=24 and ships TypeScript types. Key differentiators: handles multiple SQL dialects, produces both JSON Schema (draft-07) and a compact intermediate format, supports ALTER TABLE, and allows configuration of output options like useRef for schema references. Active development with regular releases.","status":"active","version":"6.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/duartealexf/sql-ddl-to-json-schema","tags":["javascript","parse","parser","sql","ddl","format","formatter","json","schema","typescript"],"install":[{"cmd":"npm install sql-ddl-to-json-schema","lang":"bash","label":"npm"},{"cmd":"yarn add sql-ddl-to-json-schema","lang":"bash","label":"yarn"},{"cmd":"pnpm add sql-ddl-to-json-schema","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runs in Node.js environment for file system operations and CLI usage","package":"node","optional":true}],"imports":[{"note":"ESM module; named export. For CommonJS, use dynamic import or check package compatibility.","wrong":"const parseSqlToJsonSchema = require('sql-ddl-to-json-schema')","symbol":"parseSqlToJsonSchema","correct":"import { parseSqlToJsonSchema } from 'sql-ddl-to-json-schema'"},{"note":"Parses a single DDL statement and returns the compact JSON format.","symbol":"parseSqlDdlStatement","correct":"import { parseSqlDdlStatement } from 'sql-ddl-to-json-schema'"},{"note":"Converts an array of compact table objects to JSON Schema documents.","symbol":"compactToJsonSchema","correct":"import { compactToJsonSchema } from 'sql-ddl-to-json-schema'"},{"note":"Default export is the main converter function (deprecated); use named exports in v6.","wrong":"import { default } from 'sql-ddl-to-json-schema'","symbol":"default","correct":"import sqlDdlToJsonSchema from 'sql-ddl-to-json-schema'"}],"quickstart":{"code":"import { parseSqlToJsonSchema } from 'sql-ddl-to-json-schema';\n\nconst sqlDdl = `\nCREATE TABLE users (\n  id INT(11) NOT NULL AUTO_INCREMENT,\n  nickname VARCHAR(255) NOT NULL,\n  deleted_at TIMESTAMP NULL,\n  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,\n  PRIMARY KEY (id)\n) ENGINE MyISAM COMMENT 'All system users';\n`;\n\nconst result = parseSqlToJsonSchema(sqlDdl);\nconsole.log(JSON.stringify(result, null, 2));\n// Output: array of JSON Schema documents","lang":"typescript","description":"Parses a SQL DDL statement and outputs an array of JSON Schema documents."},"warnings":[{"fix":"Use import syntax or configure your project for ESM.","message":"In v6, ESM is required; CommonJS require() will fail.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Use import { parseSqlToJsonSchema } from 'sql-ddl-to-json-schema' instead of import sqlDdlToJsonSchema from 'sql-ddl-to-json-schema'.","message":"Default export removed in v6; use named exports.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"If using newer JSON Schema versions, post-process the output or use compact format and convert manually.","message":"JSON Schema output is draft-07; may not match newer drafts.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"Use Node.js version between 16 and 24, or consider using an older version of the package.","message":"Node.js engine constraint: only supports Node 16 to 24.","severity":"gotcha","affected_versions":">=6.0.0"}],"env_vars":null,"search_vec":"'-07':44 '16':27 '24':28 '6.0.0':24 'activ':64 'allow':54 'alter':51 'compact':20,47 'configur':55 'convert':12 'ddl':3,9,73 'develop':65 'dialect':38 'differenti':34 'document':17 'draft':43 'format':22,49,74 'formatt':75 'handl':35 'intermedi':48 'javascript':69 'json':5,15,21,41,76 'key':33 'like':59 'multipl':36 'node.js':26 'option':58 'output':57 'pars':7,70 'parser':71 'produc':39 'refer':63 'regular':67 'releas':68 'schema':6,16,42,62,77 'ship':30 'sql':2,8,37,72 'sql-ddl-to-json-schema':1 'statement':10 'support':25,50 'tabl':52 'type':32 'typescript':31,78 'useref':60 'version':23","created_at":"2026-06-05T17:01:58.713159+00:00","updated_at":"2026-06-05T17:01:58.713159+00:00","problems":[{"fix":"Add \"type\": \"module\" to your package.json or use .mjs extension.","cause":"The project is using ESM imports but the environment is not configured for ESM.","error":"SyntaxError: Cannot use import statement outside a module"},{"fix":"Ensure you are importing from 'sql-ddl-to-json-schema' and using the correct export name. Check version compatibility.","cause":"Incorrect import path or missing export.","error":"TypeError: parseSqlDdlStatement is not a function"},{"fix":"Verify the SQL string contains valid DDL statements (e.g., CREATE TABLE).","cause":"Empty input or unsupported SQL syntax.","error":"Error: No DDL statements found"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/duartealexf/sql-ddl-to-json-schema","github":"https://github.com/duartealexf/sql-ddl-to-json-schema","docs":null,"changelog":null,"pypi":null,"npm":"sql-ddl-to-json-schema","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}