Online SQL Beautifier & Query Formatter
Rate this tool
0 of 0 ratings
Additional page content: Editable from the admin panel -> tools content.
Programmatic Code Snippets: Format & Beautify SQL Queries
How to implement Format & Beautify SQL Queries programmatically in Python, Node.js, PHP, and CLI
Format SQL queries using sqlparse library in Python
# pip install sqlparse
import sqlparse
query = "SELECT u.id, u.name FROM users u WHERE u.status = 'active' ORDER BY u.created_at DESC;"
formatted_sql = sqlparse.format(query, reindent=True, keyword_case='upper')
print(formatted_sql)
Format SQL using sql-formatter in Node.js
// npm install sql-formatter
const { format } = require('sql-formatter');
const query = "SELECT u.id, u.name FROM users u WHERE u.status = 'active' ORDER BY u.created_at DESC;";
console.log(format(query, { language: 'sql', tabWidth: 2 }));
Format SQL in PHP using Doctrine SqlFormatter
<?php
// composer require doctrine/sql-formatter
use Doctrine\SqlFormatter\SqlFormatter;
$query = "SELECT u.id, u.name FROM users u WHERE u.status = 'active' ORDER BY u.created_at DESC;";
echo (new SqlFormatter())->format($query);
Format SQL on CLI using npx sql-formatter
# Using npx (zero installation):
npx sql-formatter-cli -f query.sql
# Pipe query directly:
echo "SELECT id, name FROM users;" | npx sql-formatter-cli
Popular tools
10 Popular Converters
JSON Validator, Beautifier & Syntax Debugger
★
High-Entropy Secure Password Generator
★
RFC 4648 Base64 Encoder & Data URI Generator
★
Authoritative DNS Lookup & Records Inspector
★
Ping Test Tool – ICMP Echo Request/Reply
★
RFC 1321 MD5 Checksum & Hash Generator
Client-Side QR Code Reader & Data Matrix Decoder
RFC 3986 URL Encoder & Percent-Encoding Tool
Lorem Ipsum Dummy Text Generator
Online HTML Minifier & DOM Payload Optimizer