</>CodeScrub

SQL Formatter & Beautifier

Paste messy SQL. Get readable queries instantly.

IndentKeywordsLine gap
SQL Input
Formatted SQL
Output will appear here.
Ctrl + Enter formatCtrl + Shift + C copyCtrl + M toggle minify
Ad space · sql-formatter-mid

What Is SQL Formatting?

SQL formatting means applying consistent indentation, line breaks, and keyword casing to a query so it's easy for a human to read. The database engine itself ignores whitespace — every formatting choice exists purely for the people reading, reviewing, and debugging the query later. A well-formatted query is faster to scan in code review, simpler to diff in version control, and less error-prone to extend.

Supported SQL Dialects

  • Standard SQL — the ANSI standard, a safe default for most databases.
  • PostgreSQL — use for Postgres-specific syntax like ILIKE, array operators, and :: casts.
  • MySQL — use for backtick-quoted identifiers and MySQL LIMIT syntax.
  • T-SQL (SQL Server) — includes TOP, CROSS APPLY, and square-bracket identifiers.
  • SQLite — the lightweight embedded database; great for mobile and local tooling.
  • BigQuery— Google's data warehouse; supports STRUCT, UNNEST, and backtick project references.
  • Amazon Redshift — PostgreSQL-derived with Redshift extensions for warehouse workloads.
  • MariaDB — MySQL-compatible with extra features and stricter modes.
  • PL/SQL (Oracle)— Oracle's procedural SQL for stored procedures and packages.

How to Format SQL Queries

  1. Paste your SQL into the left panel (or click Sample to try it).
  2. Pick your dialect, indent size, and keyword casing — the output re-formats instantly.
  3. Hit Copy to grab the result. Everything runs in your browser; nothing is sent to a server.

SQL Formatting Best Practices

  • Uppercase keywords like SELECT, FROM, and WHERE — the most common convention across teams.
  • One clause per line — each JOIN, each AND/OR on its own line.
  • Pick one indent width (2 or 4 spaces) and stick with it across the codebase.
  • Align column lists vertically when there are more than a few of them.
  • Separate multiple statements with a blank line so a code review can tell where one query ends and the next begins.

Privacy & Security

Your SQL never leaves your browser. CodeScrub runs entirely client-side — no queries are sent to any server, stored, or logged.