SQL Formatter Pro
The query that needs formatting is rarely one you wrote by hand — it is one an ORM logged or a slow-query report coughed up as a single 900-character line. This puts it back into a shape you can argue with.
Free preview · Pro required to export. Format up to 3,000 characters of SQL free. Pro removes this limit and adds downloads.
What is SQL Formatter?
SQL Formatter is a HubToolify tool that lays a query out one clause per line, with joins indented under their FROM, or flattens it back to a single line. It is meant for developers and analysts reading a query that an ORM logged or a slow-query report printed as one long line, and for teams that diff queries in review. A tokeniser rather than search-and-replace rules reads the query, so string literals, comments and identifiers quoted with double quotes, backticks or square brackets are copied through untouched. Options cover uppercase, lowercase or as-typed keywords, 2-space, 4-space or tab indentation, leading commas, and AND and OR on their own lines. It also counts statements and lists the tables the query touches. Formatting happens in the browser, so table names and values are not uploaded. It is a Pro tool: the free preview formats and copies up to 3,000 characters of SQL, and Pro removes the limit and adds .sql downloads.
Why use this tool?
- A logged query arrives as one line. Reading it is the first step to fixing it, and that step should not take five minutes of manual spacing.
- Consistent formatting makes a query diffable, so a code review can see what actually changed.
- Queries name your tables and often carry real values in a WHERE clause, so they are the last thing to paste into somebody else's server.
How to use SQL Formatter
- Paste the query.
- Choose the keyword case and indentation your team uses.
- Switch to "One line" when you need it back in a config file or a bug report.
- Copy it, or download it as a .sql file.
Features
- A real tokeniser, so strings, quoted identifiers and comments are never reformatted
- One clause per line with joins and conditions indented under them
- Uppercase, lowercase or leave-as-typed keywords
- Leading or trailing commas, 2 spaces, 4 spaces or tabs
- A one-line mode for putting a query back into code
- Counts the statements and lists the tables the query touches
Tips
- Leading commas make it obvious when a column has been added or removed in a diff. Trailing commas read more naturally. Pick one and keep it.
- If a line is still very long after formatting it is usually a long IN list — those read better broken by hand than by a rule.
Frequently asked questions
Which SQL dialects does it handle?
The formatting is dialect-agnostic and covers the common syntax of MySQL, PostgreSQL, SQL Server, SQLite and Oracle, including their different quoting styles — backticks, double quotes and square brackets are all recognised as identifiers.
Will it change what my query does?
No. Only whitespace and keyword case are changed, and anything inside a string literal, a quoted identifier or a comment is copied through untouched.
Is my query sent to a server?
No. It is formatted entirely in your browser.
Can I try this Pro tool without an account?
Yes. Format up to 3,000 characters of SQL free. Pro removes this limit and adds downloads. A guest can open the preview 5 times; after that a free account keeps it. Your input is processed in your browser and is not uploaded.
Will upgrading keep my work?
Checkout and login open in a separate tab. Keep the workspace open to retain inputs, settings and previews. Files stay in that tab only; keep the originals in case you close or reload it. Export access is checked with the server after payment.
Your files are processed directly in your browser and are not uploaded to HubToolify's servers.