Snowflake SQL Formatter
Paste a Snowflake query and get clean, readable SQL. Snowflake-specific syntax such as QUALIFY, FLATTEN and VARIANT path access is preserved, and :name bind variables are detected as parameters.
A Snowflake query, before and after
The unformatted query below is the sample loaded into the editor above, and the output is exactly what this formatter returns for it with the default options. Nothing was tidied up by hand.
WITH ranked AS (SELECT customer_id, order_id, total, src:shipping.country::string AS country, row_number() OVER (PARTITION BY customer_id ORDER BY total DESC) AS rn FROM orders WHERE order_ts >= :start_date AND region = :region) SELECT customer_id, order_id, total, country FROM ranked WHERE rn = 1 AND total > :min_total QUALIFY row_number() OVER (ORDER BY total DESC) <= 100 ORDER BY total DESC WITH
ranked AS (
SELECT
customer_id,
order_id,
total,
src:shipping.country::STRING AS country,
row_number() OVER (
PARTITION BY
customer_id
ORDER BY
total DESC
) AS rn
FROM
orders
WHERE
order_ts >=:start_date
AND region =:region
)
SELECT
customer_id,
order_id,
total,
country
FROM
ranked
WHERE
rn = 1
AND total >:min_total
QUALIFY
row_number() OVER (
ORDER BY
total DESC
) <= 100
ORDER BY
total DESC Snowflake syntax it handles
A generic formatter mangles dialect-specific syntax or refuses it outright. These are the Snowflake constructs this formatter is tested against.
QUALIFY Recognised as a clause boundary, so editing a WHERE never runs past it.
src:path.to.field VARIANT path access is preserved and is not mistaken for a :name bind variable.
:name Bind variables are detected and grouped as fillable parameters.
LATERAL FLATTEN(...) Semi-structured expansion keeps its clause shape.
Snowflake formatter FAQ
Does it support QUALIFY?
Yes. QUALIFY is treated as a proper clause, so it is formatted correctly and a WHERE clause you edit stops before it.
Will VARIANT paths be confused with bind variables?
Colon paths into semi-structured data are handled as part of the expression, so ordinary VARIANT access is not reported as a parameter.
Can I edit the WHERE clause of a single CTE?
Yes. Every WHERE in the query is listed by the CTE that contains it, so a multi-step Snowflake query gives you one entry per step. Editing one splices the new condition back into that clause and nothing else in the query moves.
Does LATERAL FLATTEN survive formatting?
Yes. A LATERAL FLATTEN call keeps its clause shape and its named-argument arrow rather than being reflowed as an ordinary function in the FROM list, so semi-structured expansion stays readable.
Can it minify a Snowflake query?
Yes. Beautify and minify are both available, and minifying leaves string literals byte-for-byte alone — which matters when the query is going back into a stored procedure or a task definition where a changed literal changes behaviour.
What about Snowflake Scripting blocks?
The SQL statements inside are formatted normally, while BEGIN and END scripting control flow is passed through rather than re-indented as though it were query syntax. For a single SELECT — the usual case on this page — it never comes up.