webdev_sql_formatter
Reformat SQL statements with consistent indentation and keyword casing, and retrieve query statistics without connecting to a database.
Instructions
SQL Formatter and Beautifier. Reformat a SQL statement or script with consistent indentation and keyword casing, and report query statistics. Use webdev_graphql_formatter for GraphQL or webdev_json_formatter for JSON. This is a purely syntactic beautifier: it never connects to a database, runs a query, or validates that the SQL executes. Runs locally on the text you provide: read-only, non-destructive, contacts no external service, and is rate-limited (60 requests/minute for anonymous callers). Returns the formatted SQL plus statistics (keyword count, line count, referenced table names, and byte sizes).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | The SQL statement or script to format. Must not be blank. | |
| format | No | When true, reindent via the sql-formatter engine; when false, only apply keyword casing. | |
| uppercase | No | Upper-case SQL keywords (SELECT, FROM, WHERE); when false, preserve original casing. | |
| indentSize | No | Number of spaces per indent level (used only when indentType is spaces). | |
| indentType | No | Indent with spaces (honouring indentSize) or with a single tab per level. | spaces |
| addSemicolon | No | Append a trailing semicolon when the statement does not already end with one. | |
| removeComments | No | Strip block (slash-star) and line (double-dash) comments before formatting. | |
| compactMode | No | Collapse the SELECT field list onto a single line instead of one column per line. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| original | No | The submitted SQL, echoed back. | |
| formatted | No | The reindented or recased SQL output. | |
| stats | No | Size and content metrics for the statement. |