SQL Formatter

Keywords
Input SQL
Formatted SQL

SQL Formatter & Beautifier

Long SQL queries pasted from an ORM log or a one-line export are hard to read. This SQL formatter beautifies queries with consistent indentation and keyword casing, so you can understand and review them quickly.

It can also strip comments and minify a query back into a single line, and it works on the full range of standard SQL statements.

How to use the sql formatter

  1. 1Paste your SQLDrop in the query you want to clean up, however messy.
  2. 2Choose keyword casingFormat keywords as UPPERCASE or lowercase to match your team’s style.
  3. 3Remove comments or minifyOptionally strip comments, or minify the query into a single compact line.
  4. 4Copy the resultCopy the formatted SQL into your editor, migration or documentation.

Features

  • Consistent indentation and line breaks
  • UPPERCASE or lowercase keyword casing
  • Optional comment removal
  • Minify queries to a single line

When to use it

  • Reading a long query captured from an ORM log
  • Cleaning up SQL before adding it to a migration
  • Standardising query style across a team
  • Documenting a complex query clearly

Frequently asked questions

How do I format SQL online?

Paste your SQL query above and MyJson reformats it with clean indentation and consistent keyword casing. You can also strip comments or minify it.

Does it run my query?

No. The formatter only reformats the text of your SQL — it never connects to a database or executes anything. Everything happens in your browser.

Can it minify SQL?

Yes. Minify collapses the query into a single line by removing extra whitespace, which is handy for embedding it in code or config.

Related tools

Looking to learn more? Browse our JSON guides and tutorials.