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

sql-fmt-cli

v1.2.0

Published

Format and prettify SQL queries from the command line

Downloads

262

Readme

sql-fmt-cli

Format and prettify SQL queries from the command line — no dependencies, works instantly.

Install

npm install -g sql-fmt-cli

Usage

# Format an inline query
sql-fmt "select id, name from users where active=1 order by name"

# Format a file, print to stdout
sql-fmt --file query.sql

# Format a file and write back in place
sql-fmt --file query.sql --write

# Use 4-space indent
sql-fmt --indent 4 "select * from orders"

# Uppercase all keywords
sql-fmt --uppercase "select id from users"

# Pipe from stdin
cat query.sql | sql-fmt

Output Example

Input:

select u.id, u.name, o.total from users u inner join orders o on u.id=o.user_id where u.active=1 and o.total > 100 group by u.id, u.name order by o.total desc limit 10

Output:

Select u.id,
  u.name,
  o.total
From users u
Inner join orders o
On u.id = o.user_id
Where u.active = 1
  And o.total > 100
Group by u.id,
  u.name
Order by o.total desc
Limit 10

With --uppercase:

SELECT u.id,
  u.name,
  o.total
FROM users u
INNER JOIN orders o
ON u.id = o.user_id
WHERE u.active = 1
  AND o.total > 100
GROUP BY u.id,
  u.name
ORDER BY o.total DESC
LIMIT 10

Options

| Flag | Short | Description | |------|-------|-------------| | --file <path> | -f | Read SQL from a file | | --write | -w | Write formatted SQL back to the file (requires --file) | | --indent <n> | -i | Number of spaces for indentation (default: 2) | | --uppercase | -u | Uppercase all SQL keywords | | --help | -h | Show help |

Supported SQL

  • SELECT, FROM, WHERE, JOIN (all variants: INNER, LEFT, RIGHT, FULL, CROSS)
  • INSERT INTO ... VALUES, UPDATE ... SET, DELETE FROM
  • CREATE TABLE, ALTER TABLE, DROP TABLE
  • GROUP BY, ORDER BY, HAVING, LIMIT, OFFSET
  • UNION, UNION ALL, INTERSECT, EXCEPT
  • WITH (CTEs)
  • CASE / WHEN / THEN / ELSE / END
  • Subqueries with deeper indentation
  • Single-quoted string literals ('hello')
  • -- and /* */ comments preserved

License

MIT — Wilson Xu