// free tool

Snowflake SQL formatter

Format Snowflake SQL in your browser. Semi-structured paths, casts, QUALIFY and window functions come out laid out and unchanged in meaning.

The formatter reads Snowflake SQL with its PostgreSQL rules, plus the Snowflake syntax listed below.

Drop a .sql file here to open it. It is read in your browser, not uploaded.

Formatted SQL
SELECT
    o.order_id,
    o.src:customer.name::string AS customer,
    f.value:sku::string AS sku
FROM
    raw_orders o, LATERAL FLATTEN(input => o.src:items) f
WHERE
    o.loaded_at >= DATEADD(day, -1, CURRENT_TIMESTAMP())
QUALIFY
    ROW_NUMBER() OVER (PARTITION BY o.order_id ORDER BY o.loaded_at DESC) = 1

Loading the formatter…

Shortcuts in the editor: Ctrl+Enter formats and Ctrl+Shift+Enter minifies (⌘ instead of Ctrl on a Mac). Your settings are remembered in this browser and kept in the page address, so a link shares your style – never your SQL.

What the formatter does with Snowflake SQL

  • Semi-structured paths stay whole. src:customer.name::string and f.value:sku are kept written as one expression.
  • QUALIFY gets its own clause. QUALIFY is laid out like HAVING, and OVER (PARTITION BY … ORDER BY …) gets your keyword casing.
  • Casts and functions. :: casts stay tight, and LATERAL FLATTEN(input => …) named arguments are kept as written.
  • Dollar-quoted bodies are untouched, so a $$ … $$ procedure or UDF body comes out exactly as it went in.

Good to know

  • Stage references such as @my_stage/path/ are not formatted yet. SQL that contains one comes back unchanged, with a note pointing at the @.
  • Keyword casing covers standard SQL and PostgreSQL keywords, so some Snowflake-only words keep the case you typed.

Examples

Snowflake before and after

Before
select o.order_id, o.src:customer.name::string as customer, f.value:sku::string as sku from raw_orders o, lateral flatten(input => o.src:items) f where o.loaded_at >= dateadd(day, -1, current_timestamp()) qualify row_number() over (partition by o.order_id order by o.loaded_at desc) = 1
After
SELECT
    o.order_id,
    o.src:customer.name::string AS customer,
    f.value:sku::string AS sku
FROM
    raw_orders o, LATERAL FLATTEN(input => o.src:items) f
WHERE
    o.loaded_at >= DATEADD(day, -1, CURRENT_TIMESTAMP())
QUALIFY
    ROW_NUMBER() OVER (PARTITION BY o.order_id ORDER BY o.loaded_at DESC) = 1

The output uses the Standard style with 4-space indents, exactly as the formatter above produces it. Switch the style to Compact for denser SQL or Expanded for leading commas and one item per line. The formatter docs cover the details.

Snowflake formatter FAQ

How does the formatter read Snowflake SQL?

With its PostgreSQL rules, which share Snowflake's quoting, :: casts and $$ strings. On top of that it keeps col:path access together and lays out QUALIFY as a clause.

Why did it leave my COPY INTO statement unchanged?

Stage references such as @my_stage are not supported yet, so SQL containing one is returned exactly as written, with a note showing where the formatter stopped.

Is my SQL sent to a server?

No. The formatter is compiled to WebAssembly and runs inside your browser tab. Your SQL is never uploaded, logged or stored, and once the page has loaded it keeps working offline.

Can formatting break my query?

It is built not to. After formatting, SQLly checks its output token by token against your input. If anything other than whitespace and the casing you asked for would change, it gives your SQL back exactly as you wrote it and tells you why. SQL that does not parse cleanly, such as an unterminated string, is also left untouched, with the line and column of the problem.

Can I share my formatting settings with my team?

Yes. Every setting, including the advanced ones, is kept in the page address after the # sign, so copying the address or pressing Copy settings link shares your exact style. The link holds the settings only, never your SQL.

// formatting is the least of it

Like the formatter? Meet the rest of SQLly

A native SQL workbench for macOS, Windows and Linux with IntelliSense that knows your schema, guardrails for risky queries, and this formatter built into the editor.