Skip to content
uencoder
TASK

Format and beautify a SQL query

Take a minified or poorly-indented SQL query and produce readable, consistently-formatted SQL with keywords uppercased and clauses on separate lines.

  1. 1

    SQL from logs or generated by ORMs is often a single long line. Formatting with keywords on their own line, consistent indentation, and alias alignment makes it readable for debugging and review.

  2. 2
    SQL Formatter →

    Paste the SQL query. The tool formats SELECT/INSERT/UPDATE/DELETE with standard conventions: keywords uppercase, SELECT/WHERE/GROUP BY on separate lines, subqueries indented.

  3. 3
    sql-format → word-count

    Use the chain to format a SQL document with multiple statements, handling semicolons and comments consistently.

Frequently asked questions

Does formatting change the query semantics?
No — formatting only changes whitespace, capitalization, and line breaks. The parsed query tree is identical. Always verify with a diff if the formatter also 'optimizes' (some tools rewrite predicates, which can change behavior).
What SQL dialects are supported?
Standard SQL (ANSI) syntax works universally. Dialect-specific syntax (PL/pgSQL, T-SQL, MySQL backticks) may format imperfectly. The formatter focuses on the common SELECT/INSERT/UPDATE/DELETE structure.

Workflows that solve this

Learn more

Want to understand why?

Related tools