SQL Formatter
Paste your SQL and get a beautifully formatted result instantly.
Keyboard shortcuts: Ctrl/Cmd + Enter to format, Ctrl/Cmd + K to clear
SQL Toolkit
Free SQL tools that run in your browser
Paste your SQL and get a beautifully formatted result instantly.
Keyboard shortcuts: Ctrl/Cmd + Enter to format, Ctrl/Cmd + K to clear
Format and beautify SQL queries instantly with our free online SQL formatter. No signup required, works in your browser. Pick a dialect (PostgreSQL, MySQL, MariaDB, SQL Server, Oracle PL/SQL, SQLite, BigQuery, Snowflake, Redshift) or let it auto-detect.
-- comments rewritten as /* */, with one exception noted in the limits)Properly formatted SQL queries are easier to read, debug, and maintain. Whether you're working with MySQL, PostgreSQL, or SQL Server, clean SQL code helps teams collaborate and reduces errors.
Choose Standard SQL, PostgreSQL, MySQL, MariaDB, SQL Server (T-SQL), Oracle (PL/SQL), SQLite, BigQuery, Snowflake or Redshift from the dialect dropdown. Auto-detect tries Standard SQL first, then the other dialects in order of the syntax it recognises, and uses the first result that passes the safety check below. It tells you which dialect produced the output. Vendor-specific syntax the formatter cannot parse is reported as an error rather than reformatted incorrectly.
The formatter only changes whitespace and, if you ask for it, keyword case. After formatting it checks that every string, quoted name, operator, placeholder and comment came out exactly as it went in; if not, it shows the reason and leaves your SQL untouched instead of showing output that might run differently. That means some inputs are refused:
$$ bodies, and several large statements whose combined work is too high (a 5,000-row INSERT still formats). The error message names the limit it hit. Split big inputs into smaller pieces. Minify has no such limits.DELIMITER commands and PostgreSQL COPY ... FROM stdin data blocks are refused by both Format and Minify. Minify also refuses // and # comments, GO or / separator lines and psql meta-commands (backslash commands, also in the middle of a line), because joining lines would change what they mean._utf8mb4'x', Snowflake @stage/path references, two string literals joined by a line break, and the PostgreSQL <@> operator (when PostgreSQL or SQL Server is chosen; Auto-detect formats it unchanged) would be broken apart by the formatting library, so they are refused, not corrupted. Names in square brackets, such as [my column], are SQL Server and SQLite syntax; MySQL rejects them as a syntax error. A @name/… that looks like a stage path is refused in every dialect, while plain variable division such as @a/@b formats. Oracle q'[...]' strings and quotes hidden inside nested comments are also refused, with a "never closed" message that is wrong for valid SQL. Parentheses nested 500 or more levels deep are refused too.@my_stage/path, @%table or @"my stage" into a different name, so the formatter refuses the forms it recognises (after FROM, JOIN, LIST, PUT, GET, COPY INTO, in function arguments and in lists) instead of rewriting them. This check is heuristic and has not been proven complete: if your SQL uses Snowflake stages, compare the result with your input before you run it.value becomes VALUE). Choose "preserve" to keep your own casing.ON CONFLICT, ON DUPLICATE KEY and QUALIFY may keep their original case (and Auto-detect may break DO UPDATE across two lines), an Oracle ORDER SIBLINGS BY column name can be upper-cased, DECLARE @a int, @b int lists are not indented, $$ bodies are left exactly as written, and named parameters such as =:name or temp tables like ##tmp may be spaced differently from what you would write. A T-SQL money literal such as $1.50 is split into $1 .50 by the PostgreSQL reading that Auto-detect picks, so write it as a plain number. The options are the SQL Dialect, keyword case and Indent (2 or 4 spaces); there is no tab, comma-first or line-length setting.-- comment becomes /* comment */ so that joining lines cannot swallow code, except where the line break separates two string literals ('a' -- c then 'b'), which is kept as written. A -- with no space after it is kept exactly as written, on its own line, because MySQL does not read it as a comment.Yes, completely free with no signup required. All processing happens in your browser, so your SQL is never sent to our servers.
Yes! All formatting happens in your browser using JavaScript. Your SQL is never uploaded. (The page does download the code editor's own files from a public CDN, cdn.jsdelivr.net, when it loads; that request carries no SQL.) The editor does keep a draft in your own browser's local storage so you don't lose work on refresh; clear your site data to remove it, and avoid pasting sensitive SQL on a shared computer.
Use the formatting options to choose uppercase, lowercase, or preserve (keep original casing) for SQL keywords like SELECT, FROM, WHERE.
Yes, click the download button to save your formatted SQL as a .sql file.
SQL Toolkit offers a full suite of free, browser-based SQL developer tools. The tools run in your browser — no signup, and your SQL and data are never sent to our servers.
CREATE TABLE statement plus INSERT INTO rows. Column types are inferred from all rows (review them before use). Keys missing from some objects become NULL, nested objects and arrays are stored as JSON, and numbers with more than 15 digits should be put in quotes because JSON parsing rounds them.CREATE TABLE plus INSERT statements for PostgreSQL, MySQL, SQL Server or SQLite. Types are inferred from all rows; unquoted empty cells and NULL become NULL (a quoted "" stays an empty string). For very large files, use your database's bulk loader.INSERT INTO SQL statements into a clean JSON array. Useful for migrating data or feeding SQL exports into APIs and JavaScript apps. Values that are SQL expressions (for example now()) are kept as text and reported. If Auto-detect guesses the wrong dialect, choose it yourself: MySQL decodes backslash escapes and the other dialects do not.INSERT INTO SQL statements as a CSV file (UTF-8, comma-separated). Import it into Google Sheets or any data tool; in Excel use Data > From Text/CSV and choose UTF-8, otherwise accented or non-Latin characters may appear garbled. Cells that start with =, +, - or @ are written unchanged and flagged, because spreadsheets can read them as formulas.No spam. Just a message when something new is ready.