Registry / database / sql-ddl-to-json-schema

sql-ddl-to-json-schema

JSON →
library6.0.0jsnpmunverified

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.

npm install sql-ddl-to-json-schema
INSTALL
IMPORT
SIG · SQL-DDL-TO-JSON-SC
S
sql-ddl-to-json-schema
databasejavascriptv6.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parseSqlToJsonSchema
import { parseSqlToJsonSchema } from 'sql-ddl-to-json-schema'
const parseSqlToJsonSchema = require('sql-ddl-to-json-schema')
ESM module; named export. For CommonJS, use dynamic import or check package compatibility.
parseSqlDdlStatement
import { parseSqlDdlStatement } from 'sql-ddl-to-json-schema'
Parses a single DDL statement and returns the compact JSON format.
compactToJsonSchema
import { compactToJsonSchema } from 'sql-ddl-to-json-schema'
Converts an array of compact table objects to JSON Schema documents.
default
import sqlDdlToJsonSchema from 'sql-ddl-to-json-schema'
import { default } from 'sql-ddl-to-json-schema'
Default export is the main converter function (deprecated); use named exports in v6.

Parses a SQL DDL statement and outputs an array of JSON Schema documents.

import { parseSqlToJsonSchema } from 'sql-ddl-to-json-schema'; const sqlDdl = ` CREATE TABLE users ( id INT(11) NOT NULL AUTO_INCREMENT, nickname VARCHAR(255) NOT NULL, deleted_at TIMESTAMP NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, PRIMARY KEY (id) ) ENGINE MyISAM COMMENT 'All system users'; `; const result = parseSqlToJsonSchema(sqlDdl); console.log(JSON.stringify(result, null, 2)); // Output: array of JSON Schema documents
Debug
Known issues
breakingIn v6, ESM is required; CommonJS require() will fail.
fix
Use import syntax or configure your project for ESM.
affects: >=6.0.0
breakingDefault export removed in v6; use named exports.
fix
Use import { parseSqlToJsonSchema } from 'sql-ddl-to-json-schema' instead of import sqlDdlToJsonSchema from 'sql-ddl-to-json-schema'.
affects: >=6.0.0
gotchaJSON Schema output is draft-07; may not match newer drafts.
fix
If using newer JSON Schema versions, post-process the output or use compact format and convert manually.
affects: >=3.0.0
gotchaNode.js engine constraint: only supports Node 16 to 24.
fix
Use Node.js version between 16 and 24, or consider using an older version of the package.
affects: >=6.0.0
Errors
Common errors & fixes
SyntaxError: Cannot use import statement outside a module
The project is using ESM imports but the environment is not configured for ESM.
fix
Add "type": "module" to your package.json or use .mjs extension.
TypeError: parseSqlDdlStatement is not a function
Incorrect import path or missing export.
fix
Ensure you are importing from 'sql-ddl-to-json-schema' and using the correct export name. Check version compatibility.
Error: No DDL statements found
Empty input or unsupported SQL syntax.
fix
Verify the SQL string contains valid DDL statements (e.g., CREATE TABLE).
Upgrade
Version history
6.0.0latest on npm
Audit
Dependencies
nodeoptionalRuns in Node.js environment for file system operations and CLI usage
Agent activity
20 hits · last 30 days
node
16
Meta
1
Amazon
1
OpenAI (training)
1
Resources
sql-ddl-to-json-schema — npm install sql-ddl-to-json-schema · libregistry