Skip to content
pre-alpha — the TypeScript API may still shift. The SQL won't.

sqlfu includes a SQLite-focused SQL formatter. Use it from the CLI when you want to rewrite files, from ESLint when you want editor feedback, or from TypeScript when you need to format SQL programmatically.

Terminal window
npx sqlfu format "sql/**/*.sql" definitions.sql

The command accepts file paths, directories, and simple glob patterns. It rewrites files in place and reports which files changed.

Formatted files:
sql/get-posts.sql
Already formatted:
definitions.sql

The formatter is intentionally opinionated: SQLite-first, lowercase by default, and biased toward keeping simple clause bodies inline when they still read well.

The lint plugin exposes the same formatter through sqlfu/format-sql.

import sqlfu from 'sqlfu/lint-plugin';
export default [
{
files: ['**/*.sql'],
plugins: {sqlfu},
processor: 'sqlfu/sql',
rules: {
'sqlfu/format-sql': 'error',
},
},
];

Then run:

Terminal window
eslint --fix "sql/**/*.sql"

Use this when you want the formatter in the same editor and CI loop as the rest of your lint rules.

  • Lint plugin covers all SQL-aware ESLint rules.
  • CLI lists the rest of the command surface.