SQL formatter

 

Your SQL statement
Choice a database Keyword case Indentation Comments Compact mode



Formatted SQL statement





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.

User guide

This tool is an easy to use SQL formatter, you can easily format SQL online.

  • 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. This tool does not validate the syntax of your queries. If you need to check the syntax of SQL queries, you can visit our SQL validator.

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.


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




Peter Lyden-2020-02-21 21:35
Hello - using snippet to copy code from a Oracle based system. I can copy the image of the code into one note for example but then
when I use the'copy text from picture' when right clicking on the image and paste into your sql formatter or another one it doesn't seem to
copy the text correctly as some of the special characters are being converted to something else ? Any ideas why?

Thanks - can be reached @peterlyd@buffalo.edu


Nandakumar Kamat-2022-03-14 13:18
Thanks for this. I have a multi line complicated query which looked impossible to understand. Was formatted beautifully and makes it really easy to read.