Skip to content

Latest commit

 

History

History

query-formatter

README.md

@ngandu-dev/query-formatter

npm downloads Tests License

Format, compress, and highlight SQL in TypeScript, Node.js, or a terminal.

Features

  • Readable SQL formatting
  • Compact SQL compression
  • Terminal and HTML syntax highlighting
  • sql-forge command-line interface
  • No database or query-builder dependency

Requirements

  • Node.js 20 or newer

Installation

bun add @ngandu-dev/query-formatter

Quick start

import { compress, format, highlight } from "@ngandu-dev/query-formatter";

format("SELECT id,name FROM users WHERE active=1");
compress("SELECT id, name\nFROM users");
highlight("SELECT * FROM users");

Usage

Use the lower-level SqlFormatter, HtmlHighlighter, CliHighlighter, or NullHighlighter classes when you need explicit output control.

bunx sql-forge ./query.sql

Development

bun run --filter @ngandu-dev/query-formatter format
bun run --filter @ngandu-dev/query-formatter typecheck

Testing

bun run --filter @ngandu-dev/query-formatter test

Contributing

See the repository contributing guide, Code of Conduct, and pull request template.

Security

Please report vulnerabilities privately according to the repository security policy.

License

Released under the MIT License.

Contributors

Contributors