[{"data":1,"prerenderedAt":104},["ShallowReactive",2],{"tool-guide:sql-formatter":3},{"overview":4,"whatIs":5,"useCases":6,"steps":12,"commonMistakes":18,"relatedStandards":24,"comparison":37,"example":81,"limitations":85,"faq":88},"SQL Formatter rewrites query whitespace locally for thirteen SQL dialects with explicit controls for keyword case, indentation, logical operators, and script spacing.","SQL (Structured Query Language) is the standard language for managing and querying relational databases. While SQL is functionally powerful, production queries are often written as dense one-liners by ORMs, query builders, or copy-paste from logs — making them difficult to read, review, and debug. A SQL formatter parses the query, identifies keywords, identifiers, and expressions, then rewrites the whitespace to produce a consistently indented, readable version. Good formatting makes code reviews faster, bugs more visible, and team style consistent. Unlike reformatting code in languages like JavaScript or Python, SQL formatting must account for dialect differences: PostgreSQL uses $1 parameter placeholders, MySQL uses backtick quoting, SQL Server uses square brackets, and PL\u002FSQL has procedural blocks. This tool handles thirteen dialects with configurable keyword casing (UPPER, lower, or preserve), indentation depth, logical operator placement (before or after the line break), and spacing between multiple statements in a script.",[7,8,9,10,11],"Code reviews — format queries before submitting a pull request so reviewers can scan the structure instead of parsing a single line.","Debugging slow queries — format the SQL from EXPLAIN output or a slow-query log to identify missing JOINs, redundant subqueries, or incorrect WHERE clauses.","Migrating between databases — format queries in the target dialect to catch syntax differences (e.g. LIMIT vs TOP, ILIKE vs UPPER(col) LIKE).","Documentation — format example queries for README files, runbooks, or internal wikis with consistent style.","Standardizing team style — agree on casing, indentation, and operator placement, then use the formatter as the single source of truth.",[13,14,15,16,17],"Select the database dialect before formatting so vendor-specific quoting and syntax are tokenized correctly.","Choose keyword casing (UPPER, lower, or preserve), indentation (2 or 4 spaces), and logical-operator placement (before or after the line break).","For multi-statement scripts, set the spacing between statements (1 or 2 blank lines).","Paste a query or script, format it in the cancellable worker, then copy or download the reviewed SQL output.","If the parser encounters unsupported vendor syntax, it preserves the original text and flags the location.",[19,20,21,22,23],"Wrong dialect selected — each dialect has unique syntax (backtick quoting in MySQL, dollar-sign parameters in PostgreSQL). Selecting the wrong dialect may misparse identifiers or parameters.","Formatting changes semantics — in rare cases involving implicit type coercion, adding whitespace around operators can change behavior in some databases. Always test formatted queries.","Template literals in queries — ORMs often inject template strings (e.g. ${variable}) that are not valid SQL. The formatter may flag these as parse errors; format the raw SQL template, not the interpolated version.","Trailing semicolons — some tools require them, others choke on them. The formatter preserves semicolons but does not add or remove them.","Formatting stored procedures — DDL and procedural SQL (CREATE FUNCTION, BEGIN\u002FEND blocks) have limited formatting support compared to DML queries.",[25,28,31,34],{"title":26,"url":27},"ISO\u002FIEC 9075 — SQL Standard (overview)","https:\u002F\u002Fwww.iso.org\u002Fstandard\u002F76583.html",{"title":29,"url":30},"PostgreSQL SQL Syntax documentation","https:\u002F\u002Fwww.postgresql.org\u002Fdocs\u002Fcurrent\u002Fsql-syntax.html",{"title":32,"url":33},"MySQL SQL Statement Syntax","https:\u002F\u002Fdev.mysql.com\u002Fdoc\u002Frefman\u002F8.0\u002Fen\u002Fsql-statements.html",{"title":35,"url":36},"SQL Server T-SQL Reference","https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fsql\u002Ft-sql\u002Flanguage-reference",{"heading":38,"columns":39,"rows":44},"SQL dialect differences",[40,41,42,43],"PostgreSQL","MySQL","SQL Server","SQLite",[45,51,57,62,68,75],{"label":46,"values":47},"Identifier quoting",[48,49,50,48],"\"double quotes\"","`backticks`","[brackets]",{"label":52,"values":53},"Parameter placeholder",[54,55,56,55],"$1, $2","?, ?","@param",{"label":58,"values":59},"LIMIT syntax",[60,60,61,60],"LIMIT N OFFSET M","TOP N \u002F OFFSET FETCH",{"label":63,"values":64},"UPSERT",[65,66,67,65],"ON CONFLICT","ON DUPLICATE KEY","MERGE",{"label":69,"values":70},"JSON support",[71,72,73,74],"JSONB operators","JSON functions","FOR JSON","json_extract()",{"label":76,"values":77},"Case-insensitive LIKE",[78,79,79,80],"ILIKE","Default (ci collation)","LIKE (case-insensitive by default)",{"label":82,"input":83,"output":84},"Format a PostgreSQL query","select id,email from account where active=true and region=$1 order by email;","SELECT\n  id,\n  email\nFROM\n  account\nWHERE\n  active = TRUE\n  AND region = $1\nORDER BY\n  email;",[86,87],"Formatting improves whitespace and readability but does not execute, validate against a schema, or prove that a query is safe.","Template syntax and vendor extensions outside the selected dialect may be preserved imperfectly or reported as parse errors.",[89,92,95,98,101],{"question":90,"answer":91},"Which SQL dialects are supported?","PostgreSQL, MySQL, MariaDB, SQLite, SQL Server (T-SQL), Oracle PL\u002FSQL, Amazon Redshift, BigQuery, Snowflake, Spark SQL, Trino, SingleStoreDB, and a general SQL mode.",{"question":93,"answer":94},"Does the tool execute my SQL query?","No. The formatter only restructures whitespace and casing. It does not connect to a database or execute any statement.",{"question":96,"answer":97},"Can I format multiple statements at once?","Yes. Paste a multi-statement script and the formatter handles each statement, respecting the semicolon delimiter and the spacing setting between queries.",{"question":99,"answer":100},"Why does the formatter flag a parse error?","The parser follows the selected dialect. If you use syntax from a different dialect or include template placeholders that are not valid SQL, it may report a parse error at that location.",{"question":102,"answer":103},"Does formatting change how my query executes?","Formatting changes only whitespace and optionally keyword casing. It does not alter identifiers, values, operators, or query logic, so the formatted query produces the same results.",1788868140679]