{"id":15102819,"url":"https://github.com/noorzaie/sqema","last_synced_at":"2026-02-08T19:01:55.410Z","repository":{"id":57368213,"uuid":"435236996","full_name":"noorzaie/sqema","owner":"noorzaie","description":"Convert relational databases to json schema format","archived":false,"fork":false,"pushed_at":"2021-12-05T17:46:00.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-27T07:44:43.932Z","etag":null,"topics":["json-schema","postgresql","schema","sql","validation"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/noorzaie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-05T17:45:08.000Z","updated_at":"2021-12-05T17:46:51.000Z","dependencies_parsed_at":"2022-08-23T19:30:45.206Z","dependency_job_id":null,"html_url":"https://github.com/noorzaie/sqema","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/noorzaie/sqema","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noorzaie%2Fsqema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noorzaie%2Fsqema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noorzaie%2Fsqema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noorzaie%2Fsqema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/noorzaie","download_url":"https://codeload.github.com/noorzaie/sqema/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noorzaie%2Fsqema/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264229233,"owners_count":23576237,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json-schema","postgresql","schema","sql","validation"],"created_at":"2024-09-25T19:07:34.518Z","updated_at":"2026-02-08T19:01:50.369Z","avatar_url":"https://github.com/noorzaie.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"When you create a web application, you need to validate client-side inputs, most of inputs are same as database fields and you need to create validation schema manually. With `sqema` you can automatically export your sql tables to [json-schema](https://json-schema.org/) format.\n\n## Installation\n```npm\nnpm install sqema\n```\n\n## Usage\n### In scripts\n```typescript\nimport SQLToJsonSchemaConvertor from 'sqema';\n\nconst convertor = new SQLToJsonSchemaConvertor(\n    'postgres', \n    { host: 'localhost', port: 5432, database: '***', username: '***', password: '***'}\n);\n\nconvertor.generateJsonSchemas()\n    .then(() =\u003e {\n        // This will write json schemas to output directory\n        convertor.writeJsonSchemas('output', 'single-file', 'json');\n    });\n```\n\n#### `writeJsonSchemas` Options\n| Option  | Description | Possible values | Default value |\n| ------------- | ------------- | ------------- | ------------- |\n| path | Path of a directory to write schemas  | Any string  | output  |\n| granularity  | Scale of data to be written  | `single-file`: Write all schemas in single file \u003cbr\u003e `schema`: Write each schema in separate files \u003cbr\u003e `table`: Write each table in separate file \u003cbr\u003e `field`: Write each field in separate file  | single-file  |\n| format  | Format of output  | `json` \u003cbr\u003e `js` \u003cbr\u003e `ts`  | json  |\n\n### Using cli\nYou can use `sqma` command with following options:\n```\nOptions:\n  -d, --dialect \u003cdialect\u003e          database dialect (choices: \"postgres\", default: \"postgres\")\n  -h, --host \u003chost\u003e                database host\n  -port, --port \u003cport\u003e             database port\n  -db, --database \u003cdatabase\u003e       database name\n  -u, --username \u003cusername\u003e        database username\n  -p, --path \u003cpath\u003e                output folder (default: \"output\")\n  -g, --granularity \u003cgranularity\u003e  output files granularity (choices: \"single-file\", \"schema\", \"table\", \"field\", default: \"single-file\")\n  -f, --format \u003cformat\u003e            output format (choices: \"json\", \"js\", \"ts\", default: \"json\")\n  --help                           display help for command\n```\n\n## Note\nThis library currently supports `postgresql` database and also some complex data types not implemented yet.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoorzaie%2Fsqema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnoorzaie%2Fsqema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoorzaie%2Fsqema/lists"}