SQL Toolkit

Free SQL tools that run in your browser

New: Paste your CREATE TABLE SQL → get an ER diagram, data dictionary, and Markdown docs instantly.

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 Input

33 chars
Loading editor...

Formatted Output

Loading editor...

Free Online SQL Formatter

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.

Features

  • Format SQL with customizable indentation (2 spaces, 4 spaces)
  • Uppercase, lowercase, or preserve
  • Minify SQL (whitespace collapsed, strings left untouched, -- comments rewritten as /* */, with one exception noted in the limits)
  • Copy formatted SQL with one click
  • Download as .sql file
  • Privacy-first — your SQL is processed in your browser, never sent to our servers

How to Use This SQL Formatter

  1. Paste your SQL query into the editor
  2. Choose your formatting preferences (indentation, keyword case)
  3. Click "Format SQL" to beautify your query or use keyboard shortcut
  4. Copy or download the formatted result

Why Use a SQL Formatter?

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.

Supported SQL Dialects

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.

Known limits

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:

  • Size. Format refuses a single parenthesised list longer than 60,000 characters and a single statement longer than 100,000 characters (for example one INSERT with thousands of rows): the formatting library runs out of memory on those. It also estimates how long the library would take, and refuses more than about 7,900 items in one list or select list (7,900 numbers in an IN list, say), more than 25,000 tokens in one statement body, more than 20,000 statements in one paste, more than 10,000 comments and $$ 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.
  • Not SQL. MySQL 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.
  • Syntax the library splits. MySQL string introducers such as _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.
  • Snowflake stage references. The formatting library would turn a stage name such as @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.
  • The # character. It is a comment in MySQL and BigQuery but an operator in PostgreSQL. Auto-detect tells you which reading it used; choose PostgreSQL yourself if your SQL uses # as an operator.
  • Keyword case. A word that is a keyword in the chosen dialect is changed even when you used it as a name (a column called value becomes VALUE). Choose "preserve" to keep your own casing.
  • Layout details. The layout comes from the formatting library, so some vendor-specific syntax is laid out plainly: 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.
  • Minify and comments. A -- 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.

Frequently Asked Questions

Is this SQL formatter really free?

Yes, completely free with no signup required. All processing happens in your browser, so your SQL is never sent to our servers.

Can I format SQL without uploading to a server?

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.

How do I change keyword casing?

Use the formatting options to choose uppercase, lowercase, or preserve (keep original casing) for SQL keywords like SELECT, FROM, WHERE.

Can I download the formatted SQL?

Yes, click the download button to save your formatted SQL as a .sql file.

More Free SQL Tools

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.

  • JSON to SQL Converter — Paste a JSON array and instantly get a 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.
  • CSV to SQL Converter — Paste CSV (with a header row) and get a 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.
  • SQL to JSON Converter — Turn 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.
  • SQL to CSV Converter — Export 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.

Get notified when new tools launch

No spam. Just a message when something new is ready.