Select the actual dialect
MySQL, PostgreSQL, SQLite, SQL Server and Oracle have different quoting rules. Selecting PostgreSQL does not translate a MySQL query; it changes the grammar used for the operation.
Database & SQL tools
Read queries, preserve their text
Format and minify read this document and write the result back. Pasting, typing, and changing dialect, indentation, or keyword case do not rewrite it. Viewing the syntax tree does not replace the SQL.
Enter SQL or choose an example.
No connection, schema lookup, permissions check or EXPLAIN runs here. Successful formatting is not syntax validation; even a successful AST parse cannot prove a query works against your database. Only structural keywords change case; contextual words such as ACTION or NO keep their source spelling to protect identifiers.
AST accepts decimal integers and ordinary decimals with at most 15 significant digits. Exponents and hexadecimal numbers are rejected in that mode. Numeric nodes must match source values; formatting and compact output retain original precision. The AST mode uses a separate parser for four dialects. Oracle formatting remains available, while Oracle AST is explicitly unsupported. A tree is a parser interpretation, not an execution plan. Decimals need a digit before the point (use 0.5, not .5).
The first input allows 100,000 UTF-16 units, 20,000 tokens, 50 parenthesis levels and 200 statements. A generated document can continue up to 1,000,000 units. The syntax tree allows 5,000 tokens and 30 levels.
Processed locally in your browser. No database connection or saved history. Undo and redo cover edits, formatting, minifying, the example, clearing, and restoring the original. Options are not history steps.
The SQL formatter helps you review a long query before changing it in your editor. Choose the dialect that produced the source: formatting rules differ even when the SELECT statements look similar.
Use the SQL beautifier to reveal joins and nested clauses, or the SQL minifier to reduce whitespace while retaining comments. You can format SQL online without turning a formatting success into an execution guarantee.
The SQL formatter separates clauses and applies consistent indentation. Quoted text, numeric spellings and comments are checked against the source; an unsafe rewrite is rejected instead of silently exported.
The AST mode uses a separate parser for four dialects. Oracle formatting remains available, while Oracle AST is explicitly unsupported. A tree is a parser interpretation, not an execution plan.
MySQL, PostgreSQL, SQLite, SQL Server and Oracle have different quoting rules. Selecting PostgreSQL does not translate a MySQL query; it changes the grammar used for the operation.
Format and minify write the current document. Indentation and keyword case apply only to the next action. The syntax tree is a separate read-only view and has stricter numeric and complexity limits.
Pasting and changing options do not rewrite the document. Ctrl/Cmd+Enter formats, and Shift minifies. Undo restores the previous document, including manual edits.
Use sql-formatter with two spaces, four spaces or tabs and uppercase, lowercase or original keywords. Identifier, function and datatype case are left unchanged by configuration. Only structural keywords change case; contextual words such as ACTION or NO keep their source spelling to protect identifiers.
Whitespace outside tokens is reduced without deleting line comments, block comments or executable hints. PostgreSQL newline-separated string literals keep their required separation.
node-sql-parser handles its supported MySQL, PostgreSQL, SQLite and Transact-SQL subset. JSON exports contain only the returned tree, never the editor history or previous input. Viewing the tree does not replace the current SQL.
Choose a stable dialect and indentation style so joins, conditions and subqueries are easier to review. This SQL formatter separates presentation from AST inspection; always review a changed query in the context of its database.
Uppercase keywords can make clauses visually distinct, but this is a style convention. Choose lowercase or preserve if that matches your project. Quoted identifiers and string content are not converted to uppercase.
Choose compact output. It collapses outside whitespace while preserving tokens and comments, including line breaks needed for line comments or PostgreSQL adjacent string literals. It is intentionally less aggressive than a comment-removing minifier.
AST mode can report whether this parser accepts its grammar. It cannot check tables, column types, permissions or server-specific behavior. A formatter result alone gives even less assurance: it is a layout operation.
Commands such as psql backslash commands belong to the database client, not ordinary SQL grammar. Remove them from the snippet you format, keeping the original script separately; this tool does not interpret them.
Found a formatting problem?
Use the SQL formatter on the current document: format or minify writes it back, and a supported syntax tree stays read-only.