SQL Indenter and Formatter
Paste your SQL query below to format it with indentation, standardize keywords or minify it.
Paste your SQL query below to format it with indentation, standardize keywords or minify it.
SQL (Structured Query Language) is the standard language for querying and manipulating relational databases such as PostgreSQL, MySQL, SQLite, SQL Server and Oracle. SQL queries written compactly — on a single line or without consistent indentation — are hard to read, review and debug, especially when they involve multiple JOINs, subqueries or long conditional clauses.
This tool performs a heuristic formatting of the SQL query directly in your browser. The available operations are:
The tool is useful for developers who need to inspect queries generated by ORMs, review migration SQL or document complex queries in a readable way.
This is a keyword-based heuristic formatting, not a full SQL parser. It recognizes the most common clauses (SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY, HAVING, LIMIT, OFFSET, INSERT INTO, VALUES, UPDATE, SET, DELETE FROM, UNION and JOIN variants). Very unusual dialect-specific syntax or proprietary extensions may not be formatted ideally.
The tool makes a reasonable effort not to break literals between single quotes
(e.g., 'value'). However, since it is not a full parser, strings that
contain SQL keywords (e.g., 'select from') or comments
(-- comment, /* block */) may not be 100% preserved
in all cases. For queries with complex strings or comments, always check
the result before using it.
Generally yes — formatting does not change the semantics of the query, it only reorganizes whitespace and line breaks. However, since this is a heuristic formatting, it is always recommended to test the formatted query on your database before using it in production.
Formatting expands the query with indentation and line breaks to make it easier for humans to read. Minifying does the opposite: it produces a single line with normalized spaces, ideal for use in code or comparing queries.
Yes. Select the Tab option in the indent selector before clicking Format. Choosing between spaces and tab is a team preference or project convention.