SQL Formatter
Format SQL for MySQL, PostgreSQL, SQL Server, SQLite, BigQuery and Oracle.
Your SQL is formatted locally in your browser and nothing is uploaded to a server.
Working with NoSQL too? Try the MongoDB Query Formatter.
About SQL Formatter
This SQL formatter cleans up messy, single-line or unindented queries into readable, consistently styled SQL. Pick your dialect — MySQL, PostgreSQL, SQL Server (T-SQL), SQLite, BigQuery, Oracle (PL/SQL) or standard SQL — and the tool reflows SELECT, FROM, JOIN, WHERE and the rest with proper indentation. As a SQL beautifier it lets you choose 2- or 4-space indents and optionally uppercase keywords for a uniform house style. It is handy for developers reviewing pull requests, QA engineers reading logged queries, and data analysts who need to pretty print SQL straight from an ORM or a one-line dump. Use it to format SQL online before committing, diffing or sharing. Everything runs locally in your browser, so your queries are processed on your device and your data never leaves your browser.
Features
- Formats six dialects plus standard SQL: MySQL, PostgreSQL, T-SQL, SQLite, BigQuery and Oracle
- Choose 2-space or 4-space indentation for the output
- Optional UPPERCASE keyword casing for SELECT, FROM, WHERE and more
- Reflows long single-line queries into readable, indented statements
- Live formatting that updates as you type or change options
- Copy the formatted SQL or download it as a query.sql file
- Runs entirely in your browser with no tracking
How to use the SQL Formatter
- Paste your SQL into the SQL input box.
- Select your database dialect from the dropdown (e.g. PostgreSQL or MySQL).
- Pick 2 or 4 space indentation and toggle UPPERCASE keywords if you want.
- Read the beautified result in the Formatted SQL panel.
- Copy the output or download it as query.sql.
Example
Input
select id,name from users where active=1 order by name desc;
Output
SELECT
id,
name
FROM
users
WHERE
active = 1
ORDER BY
name DESC;
A single-line query reflowed with 2-space indent and uppercase keywords.
Common errors & troubleshooting
- Keywords are not uppercased even though you expected them to be. — Turn on the UPPERCASE keywords toggle; with it off, the formatter preserves your original keyword casing.
- Dialect-specific syntax is reformatted oddly or rejected. — Select the matching dialect (for example BigQuery or Oracle) so the formatter parses your syntax correctly instead of using standard SQL.
- Output indentation does not match your team style. — Switch between the 2 spaces and 4 spaces option to match your project's formatting convention.
- A syntax error in the query produces unexpected output. — Fix unbalanced parentheses or missing commas in the input; the formatter reflows valid SQL but cannot repair broken statements.
Frequently asked questions
- What is the SQL Formatter and when should I use it?
- It is a SQL beautifier that reflows messy or single-line queries into clean, indented SQL. Use it before committing, diffing in a pull request, or sharing a query with your team.
- Which SQL dialects does the SQL Formatter support?
- MySQL, PostgreSQL, SQL Server (T-SQL), SQLite, BigQuery, Oracle (PL/SQL) and standard SQL. Pick the one matching your database from the dropdown.
- How do I change the indentation width in the SQL Formatter?
- Use the 2 spaces / 4 spaces switch to set how deeply nested clauses are indented in the formatted output.
- Can the SQL Formatter uppercase keywords automatically?
- Yes. Toggle UPPERCASE keywords to standardise SELECT, FROM, WHERE, JOIN and the rest across the whole query.
- Does the SQL Formatter run or connect to my database?
- No. It only reformats the query text in your browser and never executes it or connects to any database.
- Is my SQL sent anywhere when I format it?
- No. Your query is processed locally in your browser and your data never leaves your device, so nothing is uploaded to a server.
Related tools
- MongoDB Query Formatter — Format MongoDB shell queries and aggregation pipelines.
- GraphQL Formatter — Format or minify GraphQL queries and schemas, validate syntax and extract operations.
- JS / TS Formatter — Beautify or minify JavaScript, TypeScript and JSX/TSX with Prettier options.
- HTML Formatter — Beautify or minify HTML, format inline CSS/JS, and preview the result.
- CSS / SCSS Formatter — Beautify or minify CSS/SCSS/LESS, sort properties and remove duplicates.
- XML Formatter — Beautify, minify and validate XML, and convert XML ↔ JSON.
- JSON Formatter — Beautify, minify and validate JSON with error locations.
- JSON to CSV — Convert an array of flat JSON objects to CSV.
All ArrayKit tools