SQL Formatter

Pretty-print and minify SQL queries — uppercase keywords, indent clauses, handle subqueries.

Runs 100% client-side
Copy output
On this page4 sections
Input
Output
Output will appear here…

HOW TO USE

  1. 01Paste a SQL query into the input area.
  2. 02Click Format to pretty-print, or Minify to collapse to a single line.
  3. 03Reserved keywords are uppercased; major clauses (SELECT, FROM, WHERE, JOIN, …) start a new line; AND/OR indent under the parent clause.

WHEN TO USE

Use this when you're reading or writing SQL in test setup and teardown scripts, data seeding queries, or ORM-generated queries that you want to inspect. Formatted SQL makes JOIN chains, nested subqueries, and multi-condition WHERE clauses readable at a glance — catching a missing JOIN condition or a wrong filter before the test run is cheaper than debugging a data-state failure mid-suite.

WHAT BUGS THIS FINDS

  • Incorrect JOIN condition

    A test setup query JOINs on the wrong column, silently producing a Cartesian product — formatted output makes ON clauses easy to review side by side.

  • Missing WHERE filter

    A teardown DELETE without a WHERE clause wipes the entire table; formatted SQL makes the absent clause obvious in code review.

  • Operator precedence in compound conditions

    AND/OR precedence without parentheses produces a different filter than intended — formatting indents AND/OR blocks so the logic reads unambiguously.

  • Type mismatch in comparison

    Comparing a VARCHAR column to an unquoted literal or a numeric string causes implicit conversion — readable formatting surfaces the literal type at a glance.

QA USE CASES

01

Test data setup query review

Format ORM-generated INSERT/UPDATE queries before committing them to the fixture folder, making them readable for peer review.

02

Teardown script safety check

Format DELETE and TRUNCATE scripts to confirm WHERE clauses are present and targeting the right tables before running against a shared test database.

03

Query output debugging

Paste a logged slow query, format it, and identify which JOIN or subquery is responsible for an unexpected result set during a test run.