Developer's Toolbox / Format SQL online

SQL formatter

SQL formatter tool allows to format and beautify SQL statements online. It is also a SQL minifier, you can minify SQL.

It is a instant SQL formatter, it will automatically format your SQL query in order to generate SQL pretty string.

Short user guide: Copy and paste, drag and drop a SQL query or directly type in the "Your SQL statement" editor below.
Your SQL query is automatically formatted in the "Formatted SQL statement" editor.

You can see the user guide to help you to use this online SQL editor.


Your SQL statement
Choice a databaseKeyword caseIndentation CommentsCompact mode



Formatted SQL statement






User guide

This tool is an easy to use SQL formatter.

  • How to beautify SQL? :

    There is only one step to format your SQL query, you must fill the "Your SQL statement" editor, and automatically the SQL pretty is available in the "Formatted SQL statement" editor.
    In order to fill the "Your SQL statement" editor, you can:

    • Copy and paste your SQL query.
    • Drag and drop your SQL file.
    • Directly type your SQL string in the editor.

    You have several formatting options available:

    • Choice a database:

      By default, it formats for Standard SQL, but you can also choice a database in order to correctly format the specificities.

    • Keyword case:

      You can choice the case of SQL keywords (as SELECT, FROM ...).

    • Indentation:

      You can choice the indentation: You can choose the character (between tabulation and space characters) to use and the number of times to repeat it.

    • Comments:

      You can choice to keep or remove comments.

    • Compact mode:

      You can format your SQL to one line.
      Note: Single line comments (start with --) will be convert to multi-line comments (start with /* and end with */).

  • How to minify SQL? :

    Just select the "Yes (Minify)" option of the "compact mode" parameter to minify your SQL.

  • How to retrieve the formatted SQL? :

    You can click on "Download" button in order to download the formatted SQL statement.
    You can also copy the result to the clipboard by clicking on the button "Copy to clipboard".

Note: SQL keywords appear in green all-uppercase.


SQL pretty tool

When you debug a large automatically generated query, it is often not easy to understand. SQL pretty tool makes the queries more understandable. This online SQL editor tool allows you easily to read SQL statement! This SQL beautifier is useful for SELECT, UPDATE, INSERT and DELETE statements.

Your SQL query is formatted even if your SQL statement is invalid.

You can choose the indentation level, the case of the SQL keywords, the database, whether you keep or remove comments and the compact mode.

This tool also allows to minify SQL (compress).


About SQL

SQL (Structured Query Language) is a domain-specific language used in programming for managing relational database. It allows to handle structured data where there are relations between different entities of the data.

SQL is a standard of ANSI and ISO.


About SQL Formatter library

SQL-Formatter.js is a JavaScript library for pretty-printing SQL queries. It can be used like any javascript library in a browser. It is MIT licensed.

I made some changes to add some settings. You can retrieve the updated version from the url: https://extendsclass.com/lib/sql-formatter.js Look for "// UPDATED" to find the changes.



You can report a bug or give feedback by adding a comment (below) or by clicking "Contact me" link (at the top right hand corner of the page).

Comments





Disclaimer: The tools are provided "as is", without warranty of any kind, either express or implied.
Any links to third-party website or software available on this website are provided "as is",
without warranty of any kind, either express or implied and are to be used at your own risk.