SQL Formatter
Pretty-print SQL across 11 dialects (MySQL, PostgreSQL, SQLite, BigQuery, Snowflake...). Browser-side, instant.
Pretty-print SQL across 11 dialects with indent + keyword case options. Browser-side parsing — no upload, no signup.
SQL Formatter takes a one-line minified query and pretty-prints it into readable, indented SQL — across 11 dialects. Pickrack uses the open-source sql-formatter library (15k+ GitHub stars) and exposes the most-asked-for options: dialect (MySQL, PostgreSQL, SQLite, MS SQL, BigQuery, Snowflake, Redshift, Oracle PL/SQL, MariaDB, Spark, standard SQL), indent width (2/4/8 spaces), and keyword case (UPPER, lower, preserve).
Use it when you need to drop a 300-character SELECT ... WHERE ... GROUP BY ... into a Notion doc, a code review comment, or a blog post — and the inline editor doesn't format SQL for you. Or when you inherit a legacy query and want to actually read it before changing anything.
Free, no signup, browser-side. Your SQL never leaves your tab — important for queries that contain literal customer IDs, internal table names, or other data you don't want in some random web service's logs. Errors during parsing display inline with the position so you can spot syntax issues fast.
Key features
- 11 SQL dialects — MySQL, MariaDB, PostgreSQL, SQLite, MS SQL (T-SQL), BigQuery, Snowflake, Redshift, Oracle PL/SQL, Spark, standard ANSI SQL. Each respects dialect-specific keywords and function names.
- Keyword case options — UPPER (most readable for big queries), lower (modern style — Postgres community prefers it), preserve (keep what you typed).
- Indent 2 / 4 / 8 spaces — 2 matches Prettier defaults, 4 matches PEP-8 / older SQL style guides, 8 for documents/email.
- Browser-side parsing — Queries never leave your tab. Safe for SQL that contains real customer IDs, internal schema names, or other data you don't want logged.
- Inline error reporting — Parser errors show the problem and approximate position. Doesn't run the query — just formats it.
- Load sample button — Pre-loaded JOIN + GROUP BY example to test options against without typing your own.
How to use
- Step 1: Paste your SQL — Or click 'Load sample' to see a realistic JOIN/GROUP BY query.
- Step 2: Pick the dialect — Most modern queries work fine on
Standard SQL. Pick a specific dialect if you use vendor extensions (window function syntax differs slightly across dialects, BigQuery has special date functions, etc.). - Step 3: Tweak indent and keyword case — 2-space + UPPER is the safest default for blog/docs. 4-space + lower for modern PostgreSQL projects.
- Step 4: Copy — Click Copy to put the formatted SQL on your clipboard. Paste into your editor, doc, or PR description.
When to use
- Code review — when someone PRs a one-liner 200-char
SELECT, paste here, copy the formatted version into the PR comment - Blog post / documentation — readable SQL examples that won't horizontal-scroll on phones
- Inherited legacy query — see structure before refactoring
- SQL stored as a string in code (e.g., Python ORM raw query) — extract, format, paste back
- Compare two query variants — format both with the same settings to spot real differences
- Cleanup before commit — auto-format SQL files that your editor's auto-formatter doesn't handle
Frequently asked questions
Does this run the query? Is it safe for production SQL?
It only parses and formats — never executes, never connects to any database. Safe to paste production queries with real table/column names. Everything stays in your browser tab.
What if my dialect isn't listed?
Try Standard SQL — it covers ANSI SQL features. If your dialect (e.g., DuckDB, Couchbase N1QL) has unique syntax, the formatter may misparse. Open an issue with a sample query.
Why does keyword case matter?
Style preference. SQL is case-insensitive for keywords, so SELECT and select behave identically — but consistency improves readability. UPPER traditionally separates keywords from identifiers; lower matches modern code-style. Pick one for your project and stick with it.
Can I format DDL (CREATE TABLE, etc.)?
Yes — the formatter handles DDL, DML, DCL, and stored-procedure bodies (PL/SQL, T-SQL). CTEs, window functions, JSON operators, lateral joins — all formatted correctly per dialect.
How does it handle comments?
Single-line (-- comment) and block (/* comment */) comments are preserved at their original position. Comments don't move around even if the surrounding SQL is reformatted heavily.
Does it sort keys, normalize whitespace, or modify the query?
Only whitespace + casing. The query semantics are 100% preserved — no key reordering, no * expansion, no implicit JOIN rewriting. Format-only.
Related tools
JSON Formatter
Format, validate, and minify JSON. Detects errors with line numbers. Browser-side, your data never leaves your device.
YAML ↔ JSON Converter
Convert YAML to JSON or JSON to YAML with adjustable indent. Inline error reporting.
Text Diff Checker
Compare two text blocks line-by-line with LCS algorithm. Color-coded additions/removals, ignore whitespace or case.