Good SQL Formatting
Optimize your queries for readability.
Supporting multiple dialects including GoogleSQL (BigQuery), PostgreSQL, MySQL, and Snowflake, etc.
Automation
Integrate formatting as simply as running curl in your terminal.
-- format for BigQuery dialect by default with sensible optionscat query.sql | curl -X POST --data-binary @- https://api.nidoran.work/format-sql
-- format with custom optionscat query.sql | curl -X POST --data-binary @- "https://api.nidoran.work/format-sql?dialect=bigquery&max_length=120&keyword_handling=upper_case&builtin_function_handling=lower_case&indent_cte_definitions=true&always_break_select=false&always_break_query=true&always_break_pipe=true"
Docs
The following SQL dialects are supported:
The most complete dialect is Google SQL (BigQuery), where we have a good coverage of the syntax, such as scripts and queries with pipe syntax are supported. Under the hood, we useGoogleSQLto parse the SQL queries and scripts to abstract syntax trees (AST) before applying rules to perform formatting.
For other dialects, we useDataFusion SQL Parserto parse the SQL to AST. It has a good coverage of other SQL dialects, but for some unusual features of certain dialects, this parser will not be able to parse them correctly. In this case, we won't be able to format those queries.
For bug report, please send an email to: [email protected]