SQL Formatter for JavaScript
Free online sql formatter with JavaScript code examples
Working with sql formatter in JavaScript? Our free online sql formatter helps JavaScript developers format, validate, and process data instantly. Below you will find JavaScript 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 FormatterJavaScript Code Example
const { format } = require('sql-formatter');
const 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;";
const formatted = format(sql, {
language: 'sql',
tabWidth: 2,
keywordCase: 'upper',
});
console.log(formatted);Quick Setup
Library: sql-formatter
npm install sql-formatterJavaScript Tips & Best Practices
- sql-formatter supports MySQL, PostgreSQL, T-SQL, and more
- Use the language option to match your SQL dialect
- keywordCase: 'upper' standardizes keyword casing