{"id":24795221,"url":"https://github.com/nightvisi0n/pg-formatter-ts","last_synced_at":"2026-04-28T22:34:55.833Z","repository":{"id":151252894,"uuid":"623826487","full_name":"nightvisi0n/pg-formatter-ts","owner":"nightvisi0n","description":"Format PostgreSQL SQL with ease using this TypeScript library, which provides a convenient API wrapping the `pgFormatter` CLI tool","archived":false,"fork":false,"pushed_at":"2023-04-06T07:41:23.000Z","size":210,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-14T15:15:10.703Z","etag":null,"topics":["cli-wrapper","code-formatter","database-tools","pgformatter","postgresql","query-optimization","sql","sql-formatter","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nightvisi0n.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-05T07:05:52.000Z","updated_at":"2023-04-05T14:41:45.000Z","dependencies_parsed_at":"2023-09-07T03:38:03.335Z","dependency_job_id":null,"html_url":"https://github.com/nightvisi0n/pg-formatter-ts","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/nightvisi0n/pg-formatter-ts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nightvisi0n%2Fpg-formatter-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nightvisi0n%2Fpg-formatter-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nightvisi0n%2Fpg-formatter-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nightvisi0n%2Fpg-formatter-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nightvisi0n","download_url":"https://codeload.github.com/nightvisi0n/pg-formatter-ts/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nightvisi0n%2Fpg-formatter-ts/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32402671,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T19:38:08.556Z","status":"ssl_error","status_checked_at":"2026-04-28T19:37:55.688Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["cli-wrapper","code-formatter","database-tools","pgformatter","postgresql","query-optimization","sql","sql-formatter","typescript"],"created_at":"2025-01-29T23:29:06.737Z","updated_at":"2026-04-28T22:34:55.813Z","avatar_url":"https://github.com/nightvisi0n.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pg-formatter-ts [![npm](https://img.shields.io/npm/v/pg-formatter-ts.svg)](https://www.npmjs.com/package/pg-formatter-ts) [![Coverage Status](https://coveralls.io/repos/github/nightvisi0n/pg-formatter-ts/badge.svg?branch=main)](https://coveralls.io/github/nightvisi0n/pg-formatter-ts?branch=main)\n\n![pg-formatter-ts logo](./assets/logo.png)\n\n`pg-formatter-ts` is a TypeScript library that wraps the pgFormatter CLI tool for formatting PostgreSQL SQL code.  \nWith a simple and easy-to-use API, it provides the ability to format SQL code programmatically with various formatting options.\n\nCompared to the existing [`pg-formatter`](https://github.com/gajus/pg-formatter) library, `pg-formatter-ts` offers improved TypeScript support and better integration with modern TypeScript/JavaScript projects. This library utilizes the same underlying CLI tool, but provides a more streamlined and developer-friendly API.\nAdditionally, `pg-formatter-ts` supports all available CLI options of pgFormatter, allowing for greater customization and control over the formatting process.\n\n## Installation\n\n```bash\nyarn install pg-formatter-ts\n```\n\n### Prerequisites\n\nEnsure that `perl` is installed on your system, as `pgFormatter` relies on it. You can check if Perl is installed by running `perl -v` in your command line. If it's not installed, please visit the [Perl official website](https://www.perl.org/get.html) for installation instructions.\n\n## Usage\n\n```typescript\nimport { format, PgFormatOptions } from \"pg-formatter-ts\";\n\nconst sqlCode = \"SELECT id, name, age FROM users WHERE age \u003e= 18;\";\nconst options: PgFormatOptions = {\n    keywordCase: 2,\n    spaces: 2,\n};\n\nformat(sqlCode, options).then((formattedCode) =\u003e {\n    console.log(formattedCode);\n});\n```\n\n## Options\n\n`pg-formatter-ts` accepts an optional `PgFormatOptions` object as a parameter for the `format` function. The options available are:\n\n```typescript\ninterface PgFormatOptions {\n    anonymize?: boolean;\n    commaStart?: boolean;\n    commaBreak?: boolean;\n    config?: string;\n    wrapComment?: boolean;\n    debug?: boolean;\n    commaEnd?: boolean;\n    functionCase?: number;\n    format?: string;\n    nogrouping?: boolean;\n    help?: boolean;\n    inplace?: boolean;\n    keepNewline?: boolean;\n    noExtraLine?: boolean;\n    maxlength?: number;\n    multiline?: boolean;\n    nocomment?: boolean;\n    numbering?: boolean;\n    output?: string;\n    placeholder?: string;\n    redshift?: boolean;\n    spaces?: number;\n    separator?: string;\n    formatType?: boolean;\n    tabs?: boolean;\n    keywordCase?: number;\n    typeCase?: number;\n    version?: boolean;\n    wrapLimit?: number;\n    wrapAfter?: number;\n    noRcfile?: boolean;\n    extraFunction?: string;\n    extraKeyword?: string;\n    noSpaceFunction?: boolean;\n}\n```\n\nFor a detailed explanation of each option, refer to the [pgFormatter documentation](https://github.com/darold/pgFormatter).\n\n## Disclaimer\n\nThe code for this library and this README were generated by an AI called GPT-4, developed by OpenAI. While GPT-4 strives for accuracy, it is possible that the code and documentation may contain errors or inconsistencies. Please feel free to report any issues or submit pull requests with improvements, as your contributions are welcome and appreciated.\n\n## License\n\nThis project is licensed under the [MIT License](https://opensource.org/license/mit/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnightvisi0n%2Fpg-formatter-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnightvisi0n%2Fpg-formatter-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnightvisi0n%2Fpg-formatter-ts/lists"}