SQL Formatter for TypeScript
Free online sql formatter with TypeScript code examples
Working with sql formatter in TypeScript? Our free online sql formatter helps TypeScript developers format, validate, and process data instantly. Below you will find TypeScript code examples using sql-formatter 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 FormatterTypeScript Code Example
import { format, FormatOptionsWithLanguage } from 'sql-formatter';
const sql: string = "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;";
const options: FormatOptionsWithLanguage = {
language: 'postgresql',
tabWidth: 2,
keywordCase: 'upper',
};
const formatted: string = format(sql, options);
console.log(formatted);Quick Setup
Library: sql-formatter
npm install sql-formatterTypeScript Tips & Best Practices
- sql-formatter includes TypeScript definitions
- FormatOptionsWithLanguage provides typed options
- Supports PostgreSQL, MySQL, MariaDB, SQLite, and more