A command-line utility and Node.js module to convert PostgreSQL table definitions into JSON Schema (Draft-04/07 compatible). Version 1.1.3 is the latest stable release, with active but infrequent updates. Uses pg-structure internally for schema introspection. Supports multiple PostgreSQL schemas, table inclusion/exclusion, custom base URLs, and config files. Less feature-rich than alternatives like 'db-to-jsonschema' but focused on simplicity and direct PostgreSQL integration. Written in TypeScript, ships type definitions.
npm install pg-tables-to-jsonschemaNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates how to import the converter function, connect to a PostgreSQL database, and convert tables to JSON Schema with custom options.
Update configuration to match the new format with 'pg', 'input', 'output' keys. See README or migration guide.
Use a configuration file (JSON) with the '--config' option for more reliable behavior.
Check pg-structure documentation or your table definitions. Consider custom transformations if needed.
Verify your --pg-user and --pg-password options, or use a .pgpass file. Ensure pg_hba.conf allows password authentication.
Use `const { converter } = require('pg-tables-to-jsonschema')` instead of `const converter = require('pg-tables-to-jsonschema')`.Check schema name spelling and quotes. Ensure the database user has USAGE and SELECT privileges on the schema and tables.