SQL formatter/beautifier
Format & beautify your SQL code with ease.
About this tool
The SQL formatter turns a long, hard-to-read query into neatly indented SQL, with each clause on its own line. It can also do the opposite and compress a query onto a single line.
How to use the SQL formatter
- Paste your SQL: one query or several.
- Choose the style: Format and indent, or Compress to one line.
- Choose UPPERCASE keywords, or Keep as typed.
- Press Format and copy the result.
Before and after
select id,name from users where active=1 order by name
becomes
SELECT
id,
name
FROM
users
WHERE
active = 1
ORDER BY
name
Good to know
Uppercasing changes only the SQL keywords, like SELECT and WHERE. Table and column names, strings and comments are left exactly as they were, so the query does the same thing. The formatter reads standard SQL, so it works for MySQL, MariaDB, PostgreSQL, SQLite and SQL Server queries.
Formatted SQL is easier to review, debug and share in code reviews and documentation; compressed SQL fits neatly in logs or a line of code.
Similar tools
HTML entity converter
Encode or decode HTML entities for any given input.
BBCode to HTML
Convert forum style BBCode snippets to raw HTML code.
Markdown to HTML
Convert Markdown snippets to raw HTML code.
HTML tags remover
Easily remove all HTML tags from a block of text.
User agent parser
Parse the browser, engine, operating system and device from user agent strings.
URL parser
Parse the parts and query parameters of any URL.