SQL Formatter for Rust

Free online sql formatter with Rust code examples

Working with sql formatter in Rust? Our free online sql formatter helps Rust developers format, validate, and process data instantly. Below you will find Rust code examples using sqlformat so you can achieve the same result programmatically in your own projects.

Try the SQL Formatter Online

Use our free SQL Formatter directly in your browser — no setup required.

Open SQL Formatter

Rust Code Example

use sqlformat::{format, QueryParams, FormatOptions, Indent};

fn main() {
    let sql = "SELECT u.name, u.email, o.total FROM users u JOIN orders o ON u.id = o.user_id WHERE o.total > 100 ORDER BY o.total DESC;";

    let options = FormatOptions {
        indent: Indent::Spaces(2),
        uppercase: Some(true),
        lines_between_queries: 2,
    };

    let formatted = format(sql, &QueryParams::None, &options);
    println!("{}", formatted);
}

Quick Setup

Library: sqlformat
cargo add sqlformat

Rust Tips & Best Practices

  • sqlformat is a Rust port of the popular sql-formatter
  • It supports multiple SQL dialects
  • Use QueryParams to handle parameterized queries

Frequently Asked Questions

SQL Formatter in Other Languages

More Rust Tools