Trino Formatter
Format Trino and Presto SQL with Trino rules for double-quoted identifiers, standard strings without backslash escapes, X'' and U&'' literals, array and map subscripts and lambda expressions. Clauses such as WITH, GROUP BY, ORDER BY, OFFSET and FETCH FIRST get their own lines and columns are indented one per line. Unclosed strings and parentheses are reported with line and column for analysts.
Frequently asked questions
Which Trino syntax is understood?
Single-quoted strings with doubled quotes, double-quoted identifiers and X'' varbinary and U&'' Unicode literals are recognized. Array[1] and map['key'] subscripts and lambda expressions such as x -> x + 1 stay intact.
Do backslashes escape characters in strings?
No. In Trino a backslash inside a string is an ordinary character, and the formatter follows that rule, so 'C:\' is a complete string.
Can I format Presto and Amazon Athena queries?
Yes. Presto and Athena share Trino's quoting rules and most of its syntax, so their queries format the same way.
How are catalog and schema names handled?
Qualified names such as hive.sales.orders and "my-catalog"."schema"."table" stay joined. No spaces are added around the dots.
Which clauses get their own line?
WITH, SELECT, FROM, WHERE, GROUP BY, HAVING, WINDOW, ORDER BY, OFFSET, LIMIT and FETCH start their own lines. The set operators UNION, INTERSECT and EXCEPT separate the queries they combine.
Does it support MERGE?
Yes. WHEN MATCHED and WHEN NOT MATCHED branches start new lines.
Does it change keyword case?
No. Keywords and names keep the case you wrote. Only whitespace and line breaks change.
Which errors are detected?
Unclosed strings, quoted identifiers, subscripts and block comments, and unbalanced parentheses, each with line and column. Queries are not run against any cluster.
How large can the input be?
Up to 1 MB per request and 128 KB per statement. Several statements are separated by blank lines.
Can I choose the indentation, and is my SQL stored?
Use 2 or 4 spaces or tabs. The SQL is formatted in memory only and never saved.