https://github.com/takeokunn/rs-sql-indent
A Rust-based SQL formatter and indenter
https://github.com/takeokunn/rs-sql-indent
formatter rust sql
Last synced: 16 days ago
JSON representation
A Rust-based SQL formatter and indenter
- Host: GitHub
- URL: https://github.com/takeokunn/rs-sql-indent
- Owner: takeokunn
- License: mit
- Created: 2026-02-11T04:12:14.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2026-04-29T09:18:38.000Z (about 2 months ago)
- Last Synced: 2026-05-04T18:48:52.199Z (about 1 month ago)
- Topics: formatter, rust, sql
- Language: Rust
- Homepage: https://sql-indent.takeokunn.org/
- Size: 127 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rs-sql-indent
A fast, opinionated SQL formatter CLI tool written in Rust.

## Features
- Token-stream based formatting -- no AST parsing, no external dependencies
- Four formatting styles: **Basic**, **Streamline**, **Aligned**, and **Dataops**
- Uppercase/lowercase keyword control
- Zero-copy lexer for fast execution
- Reads from stdin -- works with pipes and redirects
- [Playground](https://takeokunn.github.io/rs-sql-indent/) -- try it in your browser via WebAssembly
## Install
```sh
cargo install --git https://github.com/takeokunn/rs-sql-indent.git
```
## Usage
```sh
echo "select id, name from users where active = true" | rs-sql-indent
```
```sh
rs-sql-indent < query.sql
```
### Options
| Flag | Description |
| ----------------- | ----------------------------------------------------------------------- |
| `--style ` | Formatting style: `basic` (default), `streamline`, `aligned`, `dataops` |
| `--lowercase` | Output keywords in lowercase |
```sh
echo "select id, name from users" | rs-sql-indent --style aligned
echo "select id, name from users" | rs-sql-indent --style streamline
```
## Formatting Styles
**Basic** (default) -- 4-space indent, uppercase, trailing comma:
```sql
SELECT
id,
name,
email
FROM
users
WHERE
active = TRUE
ORDER BY
name
```
**Streamline** -- 2-space indent, trailing comma:
```sql
SELECT
id,
name,
email
FROM
users
WHERE
active = TRUE
ORDER BY
name
```
**Aligned** -- right-aligned keywords, uppercase, leading comma:
```sql
SELECT id
, name
, email
FROM users
WHERE active = TRUE
ORDER BY name
```
**Dataops** -- 4-space indent, uppercase, leading comma:
```sql
SELECT
id
, name
, email
FROM
users
WHERE
active = TRUE
ORDER BY
name
```
## Build
```sh
cargo build --release
```
## License
MIT -- see [LICENSE](LICENSE) for details.