npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

universal-ddl

v0.3.2

Published

Parses a DDL script in a universal format, then generates DDL scripts for several DBMS.

Readme

Universal DDL — universal-ddl

Build Status Dependencies Status Codacy Badge npm Type definitions GitHub

Parse DDL scripts in a universal format, then generates DDL scripts for several DBMS.

This package provides a CLI and a programmatic API for Node.js.

How to use the Command Line Interface

Example:

npx universal-ddl --autofix --postgresql --sqlite path/to/ddl-file.sql

This command will generate two new files path/to/ddl-file.postgresql.sql and path/to/ddl-file.sqlite.sql.

Available options:

  -h, --help                   Print this help message.
  -a, --autofix                Enable autofix.
  -o, --output-dir directory   The output directory (optional).
  -p, --postgresql             Generate a DDL for Postgresql.
  -s, --sqlite                 Generate a DDL for SQLite.
  -m, --mariadb                Generate a DDL for Mariadb or MySQL.
  -u, --universal-ddl          Generate a DDL using the Universal DDL syntax.
  -d, --generate-drop          Generate drop statements (except for the Universal DDL output).
  -e, --encoding string        Encoding for input and output file(s) (default is utf8).
  -f, --force                  Overwrite output files.
  --src file                   The source file (by default at last position).

How to use the API from Node.js

Install as a dependency:

npm install universal-ddl

Then, use it:

const {
  parseDdl,
  generateDdl,
  createRds,
  parseDdlToRds,
} = require("universal-ddl");

const input = `
  create table t1 (
    a integer not null primary key autoincrement
  );
  `;

// Parse the input DDL and create an AST
const ast = parseDdl(input, {
  autofix: true,
  checkConsistency: true,
  freeze: true,
});

// The AST is a pure JSON format, it can be stringified
console.log(JSON.stringify(ast, undefined, 2));

// How to generate a specific DDL for your DBMS
console.log(generateDdl(ast, "postgresql"));

// Create a RDS (Relational Database Structure). It is a POJO object, higher
// level than an AST. It is recursive, so it can't be stringified.
const rds = createRds(ast, { freeze: true });

// Or, create the same RDS using a shortcut
const rds2 = parseDdlToRds(input, { autofix: true, freeze: true });

// Use the RDS
console.log(rds.tables["t1"].columns["a"].constraints.notNull); // true

Contribute

Install and build

We need a JVM (Java Virtual Machine) to build the parser because we use ANTLR, which is a Java program. So, at first, install a JVM on your system.

In a terminal, open the cloned universal-ddl/ repository. Then:

# Download once the ANTLR JAR file in the project's root directory
wget https://www.antlr.org/download/antlr-4.7.2-complete.jar

# Install once all Node.js dependencies
npm install

# Build
npm run build

# Run tests
npm run test

Development environment

With VS Code, our recommanded plugins are:

  • ANTLR4 grammar syntax support from Mike Lischke (mike-lischke.vscode-antlr4)
  • TSLint from Microsoft (ms-vscode.vscode-typescript-tslint-plugin)