Skip to content
UtilPick.
My toolbox
All tools
Favorites
Saved tools

Loading…

Recently used

Tools you open will appear here.

Get the desktop app
Settings
UtilPick.
All tools
All tools/SQL Formatter

SQL Formatter

Reformat a SQL query with readable line breaks and indentation. Nothing you enter is sent to a server.

Loading the tool…

User reviews

No reviews yet. If you’ve used this tool, be the first to leave one.

User reviews

No reviews yet.

Write a review

Checking your sign-in status…

    From first step to finished result

    SQL Formatter: complete guide

    Walk through the steps and examples, or jump straight to the topic you need.

    How to use
    Examples & choices
    Troubleshooting
    FAQ

    At a glance

    What it does
    It changes only line breaks, indentation, and keyword case.
    What it doesn't touch
    The content inside strings and comments.
    What it recognizes
    '' escapes, dollar quoting, "name" · `name` · [name], operators such as ->> · <=> · ::, and :id · @name · MyBatis #{id} · ${name} placeholders.
    What you can choose
    The database (standard SQL, MySQL, PostgreSQL, Oracle, SQL Server, SQLite), keyword case, indent width (0-8), and comma position.
    To one line
    It shrinks whitespace to a minimum, but starts a new line after a line comment.
    Self-check
    It compares the tokens before and after formatting and shows the result on screen.
    What it only reports
    Mismatched parentheses and quotes. It does not fix them.
    Size
    Up to 200,000 characters. Nothing is sent to a server.

    How to use SQL Formatter

    1. 1. Paste your SQL

      01Paste your SQL

    2. 2. Choose keyword case and indentation

      02Choose keyword case and indentation

    3. 3. Copy the formatted result

      03Copy the formatted result

    1. 01

      Paste your SQL

      It's fine if it is all on one line. You can also paste several statements joined with semicolons as they are.

    2. 02

      Set the database and keywords

      Choose the database you use and it reads the query with that grammar. Choose keywords as UPPER, lower, or Keep, and set the indent width. You can also put commas at the start of lines.

    3. 03

      Check that the content is unchanged

      If "Checked: the content is unchanged." appears above the result, the substance has not changed. If it says the content changed, don't use that result.

    4. 04

      Copy or save

      You can copy the result or save it as a .sql file.

    What it’s good for

    What is inside strings and comments is left untouched

    Swapping parts of a query with regular expressions also changes a select or semicolon that sits inside a string, which breaks the query. This tool splits the query into tokens with the widely used sql-formatter engine and then reassembles it, so it knows exactly where strings and comments begin and end. It also recognizes quotes escaped by doubling a single quote, dollar-quoted strings, and names wrapped in double quotes, backticks, or square brackets as a whole.

    It checks for itself that the content is unchanged

    Tidying only changes line breaks, indentation, and the case of keywords, so the substance must stay the same. This tool compares the tokens before and after formatting to confirm they match and shows the result on screen. If they ever differ, it clearly tells you not to use the result.

    Worked examples

    Expanding a one-line query

    Input and settings
    select a,b from t where x=1 order by a
    Result
    SELECT
      a,
      b
    FROM
      t
    WHERE
      x = 1
    ORDER BY
      a
    Each clause starts on a new line and what's inside it is indented.

    Inside a string stays as is

    Input and settings
    select 'select * from users' as t
    Result
    SELECT
      'select * from users' AS t
    Even though keywords are turned to uppercase, the select inside the string stays as it is.

    What changes and what stays

    Swipe the table sideways to see the rest.

    What changes and what stays
    ItemHandlingWhy
    Line breaks and indentationChangedMaking it easy to read is this tool's job.
    Keyword caseChanged as you chooseSQL doesn't care about keyword case.
    Case of namesLeft as isFor names wrapped in quotes, case changes the meaning.
    Inside strings and commentsLeft as isChanging even one character changes the result.

    When the result isn’t what you expected

    It says it couldn't read it with the grammar

    The query may mix in notation that differs from the grammar of the database you chose. Try changing the database, for example backticks (`) for MySQL, square brackets ([ ]) for SQL Server, and # comments for MySQL. Minifying to one line works regardless of the database.

    It says the parentheses don't match

    The query itself has unmatched parentheses. It doesn't fix them and formats it as it is, so please check the result.

    It says the content changed

    That is a problem with this tool. Don't use that result; use your original. If you tell us which query it was, we will fix it.

    I don't want it changed to uppercase

    If you set keywords to "Keep," the case of the original text is kept.

    Key terms

    Token
    A unit a query is split into, such as words, strings, and comments.
    Dollar quoting
    A string wrapped in $$. You can freely put quotes inside.
    Keyword
    A word SQL has reserved, such as SELECT and FROM.
    CTE
    A temporary result set that begins with WITH.

    SQL Formatter FAQ

    Which database's SQL does it support?

    You can choose from standard SQL, MySQL, PostgreSQL, Oracle (PL/SQL), SQL Server (T-SQL), and SQLite. It reads the query using the grammar of the database you choose, and leaves MyBatis #{…} and ${…} placeholders as they are.

    Does it also tell me if the query is wrong?

    If it can't read the query with the grammar of the database you chose, it tells you, and it also tells you if parentheses or quotes don't match. It does not fix them for you.

    Is my query uploaded to a server?

    No. It is formatted only inside this browser. You can paste queries that contain real data as they are.

    Does it format a query with wrong syntax?

    If it can't read the query with the grammar of the database you chose, it doesn't format it and tells you. That is better than forcing line breaks and changing the meaning. Minifying to one line can still be used as it is.

    Can I put in several statements at once?

    Yes. It splits at each semicolon and separates them with blank lines.

    What happens to comments when I minify to one line?

    Comments are not deleted. However, it always starts a new line after a line comment. Otherwise whatever comes after would be swallowed by the comment and break the query.

    Jump to a topic

    • #SQL formatter
    • #keep strings
    • #self-check
    • #keywords
    • #matching parentheses
    • #multiple statements

    Reviewed 2026.09.30

    Related tools

    View all
    JSON FormatterDeveloper
    Regex TesterDeveloper
    Text CompareText
    UtilPick

    Simple tools for a complicated day. A free collection of online utilities.

    Service

    About UtilPick Get the desktop app

    Help

    Request a toolReport a problemContactinfo@utilpick.com

    Policies

    Privacy Policy (Korean)Terms of Use (Korean)
    Business registration no. 365-47-00936 (Republic of Korea)
    © 2026 UtilPick
    Featured on Twelve ToolsUtilPick - Featured on Startup FameFazier badgeFeatured on LaunchIgniter
    HomeSearchSavedMore
    Readable lines and indentation

    Your SQL

    Characters
    235
    Lines
    4
    Statements
    1
    Comments
    0

    Press Ctrl+Enter (⌘+Enter on Mac) to copy the result.

    Formatted SQL

    Loading the formatter…

    Keywords
    Only line breaks and indentation change

    Not a single character inside strings or comments is touched.

    How formatting works

    Only line breaks and indentation change; the meaning of the query is untouched. Nothing inside strings or comments is altered. SQL syntax differs slightly between databases. Pick yours and the query is formatted with its grammar. MyBatis #{…} and ${…} placeholders are left as they are.