SQL Formatter
Paste a SQL query on the left and get a neatly indented, readable version on the right. Choose the SQL dialect that matches your database for the most accurate result. Nothing is sent to a server.
Tip. This tool beautifies (reformats) SQL — it does not validate whether the query is semantically correct or would run successfully against a real database. Pick the dialect closest to the database you use for the best formatting result. If the query can't be parsed at all (for example, unbalanced parentheses or quotes), an approximate error location is shown. Keywords are uppercased by default, following common SQL style conventions. This tool bundles the open-source sql-formatter library (MIT License) locally, so formatting still happens entirely in your browser.
How to use this tool
- Paste your SQL query into the input box on the left.
- Pick the "SQL dialect" that matches your database (MySQL, PostgreSQL, SQL Server, and more) for the most accurate formatting.
- Click "Format" (or just wait — it also formats automatically as you type) to see the beautified result on the right.
- If the query can't be parsed, you'll get an approximate line/column for where the problem is.
- Use the indent-size dropdown to control the output indentation, then "Copy" or "Download result" to grab it.
- Everything happens in your browser — your SQL is never sent to a server.
Related tips
- This tool formats/beautifies SQL — it doesn't check whether the query is valid against your actual database schema or would execute successfully.
- Different dialects have different keyword sets and syntax quirks (e.g. LIMIT vs TOP, backticks vs double quotes); pick the one matching your database for best results.
- Keywords (SELECT, FROM, WHERE, and so on) are uppercased automatically, a common convention for readability.
- Need to also work with JSON or XML? Try the dedicated JSON Formatter, XML Formatter, or JSON ↔ XML Converter tools linked below.