Skip to main content
Convert2JSON Tools

SQL Formatter

Turn a long single-line query into properly indented SQL that shows its structure at a glance.

Your data stays on your device

Input — SQL

characters
0
lines
0
size
0 B

Output — Formatted SQL

characters
0
lines
0
size
0 B

Options

About this tool

Queries that come out of an ORM log or an application trace arrive as one enormous line. Understanding a five-way join in that form is close to impossible; formatting it reveals the structure immediately.

The formatter is dialect-aware, so PostgreSQL, MySQL, SQLite, BigQuery and several others are parsed with their own keyword sets and syntax quirks rather than a generic approximation.

How to use this tool

  1. Paste the SQL query you want to format.
  2. Select the dialect that matches your database.
  3. Choose keyword casing and indentation width.
  4. Press Format and copy the readable query.

Key features

  • Dialect support for PostgreSQL, MySQL, MariaDB, SQLite, BigQuery, Db2 and more
  • Keyword casing: uppercase, lowercase or preserved
  • Configurable indent width
  • Clause-aware line breaking for SELECT, FROM, WHERE, JOIN and GROUP BY
  • Comments preserved in place
  • Multiple statements formatted in one pass

Example

A one-line query made readable

InputSQL

select id,name from users where active=true order by name

OutputSQL

SELECT
  id,
  name
FROM
  users
WHERE
  active = true
ORDER BY
  name

Good to know

  • Formatting is syntactic only. The query is never executed and is not checked for semantic validity.
  • Vendor-specific extensions outside the selected dialect may not break onto lines ideally.
  • Parameter placeholders are preserved verbatim, not substituted.

Frequently asked questions

Does the tool run my query?

No. There is no database connection of any kind. The text is parsed and re-printed in your browser.

Why choose a dialect?

Keyword sets and syntax differ. Selecting the right dialect means constructs like PostgreSQL casts or BigQuery array syntax are formatted correctly instead of being mangled.

Should keywords be uppercase?

It is the long-standing convention and makes the shape of a query easier to scan. Some teams prefer lowercase; the option exists either way.

Are my comments kept?

Yes. Both line and block comments are preserved at their original positions.

Your data stays on your device

Your data is processed locally in your browser and is not uploaded to our server. This page keeps working after you go offline, because there is nothing to send.

Share this toolXLinkedInHacker News