How to use the SQL Formatter
Beautify long, ORM-generated, or copy-pasted SQL queries into clean, readable code with consistent indentation, keyword casing, and line breaks. The SQL Formatter supports PostgreSQL, MySQL, SQL Server (T-SQL), BigQuery, Snowflake, SQLite, and standard SQL — and can visualize CREATE TABLE statements as a schema diagram. Everything runs in your browser; queries never leave your machine.
What it does
- Pretty-prints SELECT, INSERT, UPDATE, DELETE, MERGE, CTEs (WITH), window functions, and subqueries.
- Supports dialects: PostgreSQL, MySQL, SQL Server, BigQuery, Snowflake, SQLite, Redshift, and standard SQL.
- Configurable keyword casing (UPPER, lower, capitalize) and indent (2, 4, tab).
- Preserves comments (
-- and /* */) and string literals.
- Visualizes CREATE TABLE schemas as a table diagram with columns, types, and primary keys.
- Copy formatted SQL straight to your editor, ticket, or pull request.
When to use it
- Review a long query before approving a PR.
- Make ORM-emitted SQL (Hibernate, Sequelize, Django) human-readable for debugging.
- Clean up SQL pasted from slow-query logs, EXPLAIN output, or chat.
- Enforce team style on a CTE-heavy report query.
- Get a quick schema diagram from a
CREATE TABLE dump.
- Prepare SQL for documentation or runbooks.
How to use it
- Paste your SQL into the editor.
- Pick the SQL dialect to get dialect-aware keyword handling.
- Choose keyword casing (UPPER recommended for readability) and indent size.
- Click Format (or use the keyboard shortcut). Copy the formatted SQL.
- For
CREATE TABLE input, switch to the schema diagram view to see columns and relationships.
- For building lists of values, hand off to the SQL IN Clause Builder; for joins, try the SQL Join Builder.
Tips & pitfalls
- Pick the right dialect — quoting (
" vs `), reserved words, and functions differ across PostgreSQL, MySQL, and T-SQL.
- Format does not validate — invalid SQL is still formatted, and parse errors are surfaced when they occur.
- Long
SELECT lists read best with one column per line; long WHERE clauses split on AND / OR.
- Inline comments (
--) are preserved on their original lines; align them after formatting if needed.
- For very long queries, format incrementally — large CTEs are easier to review in chunks.
FAQ
- How do I format SQL online? Paste the SQL, pick the dialect, and click Format. Copy the result.
- Which SQL dialects are supported? PostgreSQL, MySQL, SQL Server (T-SQL), BigQuery, Snowflake, SQLite, Redshift, and standard SQL.
- Does it run my SQL? No — only formatting and visualization. SQL is never executed or sent to a server.
- Can it format ORM-generated SQL? Yes — paste raw SQL emitted by Hibernate, Sequelize, ActiveRecord, or any ORM and the formatter handles it.
- How do I visualize a CREATE TABLE schema? Paste the
CREATE TABLE statements; switch to the diagram view to see columns, types, primary keys, and foreign-key links.
- Is my SQL uploaded? No. Formatting runs entirely in your browser.
Runs locally in your browser. No uploads. No analytics on pasted SQL.