SQLFormatter
FormatterConvertPricingDocsGet Pro
Formatter & beautifier · Redshift

Format & beautify Redshift SQL online

Format and beautify Redshift SQL: consistent indentation, aligned clauses, uppercase keywords — and minified one-liners expanded back into readable code.

1Paste your Redshift query into the editor.
2Press Format — or ⌘↵.
3Copy clean, highlighted SQL.
Open formatter
before
select s.user_id,listagg(s.event,',')within group(order by s.ts) as events,count(*) n from sessions s where s.ts>dateadd(day,-7,getdate()) group by s.user_id having count(*)>3 order by n desc limit 500;
Redshift
SELECT
  s.user_id,
  listagg(s.event, ',') within GROUP (
    ORDER BY
      s.ts
  ) AS events,
  count(*) n
FROM
  sessions s
WHERE
  s.ts > dateadd(day, -7, getdate())
GROUP BY
  s.user_id
HAVING
  count(*) > 3
ORDER BY
  n DESC
LIMIT
  500;

Why format Redshift?

Amazon Redshift shares Postgres roots but adds its own functions — LISTAGG … WITHIN GROUP, DATEADD/DATEDIFF, GETDATE() and distribution-aware SQL. The formatter parses Redshift grammar so LISTAGG ordering and date arithmetic format cleanly rather than breaking.

Ideal for the wide analytical queries that come out of the Redshift query editor or a BI tool, where aggregation over event data arrives as one long line.

Beautify minified Redshift SQL

Redshift reporting queries — DATE_TRUNC buckets, COUNT(DISTINCT), positional GROUP BY — get long, and BI tools emit them minified. Beautifying spreads the grouping and aggregates across indented lines so the report's logic is readable.

Once the buckets and aggregates are laid out vertically it's far easier to spot an expensive COUNT(DISTINCT) or a scan that should be filtered earlier — the first move before checking the query plan.

minified
SELECT date_trunc('week',s.ts)wk,s.channel,count(distinct s.user_id)users,sum(s.value)rev FROM sessions s WHERE s.ts BETWEEN '2026-01-01' AND '2026-06-30' GROUP BY 1,2 HAVING sum(s.value)>0 ORDER BY wk,rev DESC;
Redshift · beautified
SELECT
  date_trunc('week', s.ts) wk,
  s.channel,
  count(DISTINCT s.user_id) users,
  sum(s.value) rev
FROM
  sessions s
WHERE
  s.ts BETWEEN '2026-01-01' AND '2026-06-30'
GROUP BY
  1,
  2
HAVING
  sum(s.value) > 0
ORDER BY
  wk,
  rev DESC;

Frequently asked questions

Does the formatter understand Redshift-specific syntax?

Yes. The query is parsed against Redshift grammar rather than generic SQL, so Redshift-only constructs survive formatting: LISTAGG, DATEADD/GETDATE, distribution-aware SQL.

What is the difference between formatting and beautifying Redshift SQL?

Nothing — they are two names for the same operation. "Format" usually describes tidying SQL you wrote yourself; "beautify" usually describes expanding a minified or ORM-generated one-liner into readable lines. This page does both, with a worked example of each above.

Is my SQL uploaded anywhere?

No. Formatting runs entirely in your browser — the query never leaves your machine and nothing is stored on a server.

Is the Redshift formatter free?

Yes: free, no account, no usage limit. Only the optional AI features — explain, optimize and dialect conversion — require signing in.

All SQL formatters & beautifiers

Format PostgreSQLFormat MySQLFormat T-SQLFormat SQLiteFormat BigQueryFormat OracleFormat SnowflakeFormat Redshift