SQL Formatter
Format SQL for SQL, MySQL, PostgreSQL or SQLite, or compact whitespace. Output is plain text; queries are never executed.
Choose “Dialect”, paste SQL, then use “Format” or “Compact”. Input or option changes require another action. Method and limits
Lines:
- Input (Bytes)
- Output (Bytes)
- Input / Output (Lines)
Lines:
Method and limits
Method and limits
sql-formatter 15.6.12 formats the selected SQL, MySQL, PostgreSQL or SQLite syntax with two or four spaces. Checked uppercase changes keywords; unchecked preserves their original case. Compact mode uses a separate lexical scanner: quoted strings and identifiers, comments and hints stay intact. Horizontal whitespace is reduced, but original separating newlines remain, including PostgreSQL adjacent string literals. MySQL assumes default backslash escapes, without ANSI_QUOTES or NO_BACKSLASH_ESCAPES modelling. Unterminated tokens and DELIMITER directives are rejected. Queries are never executed; formatting does not validate tables, optimize queries or support arbitrary stored procedures.
Tool input is processed locally in a worker, without uploads, storage or source logging. Ads and the rest of the site may make network requests. Assets must load first; offline operation is not guaranteed.
Input 1 MiB UTF-8; output 2 MiB; 5 s including loading. CSS/HTML: depth 128, nodes 50000. Worker termination mitigates resources; it is not heap isolation.
Copied
Copy failed. Select the result and copy it manually.
About SQL Formatter
The SQL Formatter breaks a one-line query into readable form: SELECT, FROM, WHERE, JOIN, GROUP BY, HAVING, ORDER BY, LIMIT and UNION each begin a new line, AND, OR and ON are indented beneath them, and the select list is split one column per line at 2 or 4 spaces.
SELECT 'a--b' AS x, 'FROM, /*x*/' AS y;
Versioned technical method; no calendar or legal reference year applies.
Use Cases
How to use
Paste SQL into “Input”, or use “Load sample” to load an example.
Choose “Dialect”, paste SQL, then use “Format” or “Compact”. Input or option changes require another action.
Check “Uppercase keywords” to uppercase SELECT, FROM, JOIN and WHERE; uncheck it to preserve keyword case.
Select 2 or 4 spaces in “Indent”; this and “Uppercase keywords” affect “Format” only.
Read “Output” and compare the “Lines” counts.
Use “Copy” for the clipboard or “Download” to save query.sql.
Use “Clear” to empty the draft and result; “Cancel” stops current work.
Pro Tips
- Use keyboard shortcuts (Ctrl/Cmd+A to select all, Ctrl/Cmd+C to copy) to speed up your workflow inside the SQL Formatter.
- The SQL Formatter does not log or store your input. If you need history, copy important outputs to a local file or note app.
- Review warnings and the output before copying. A successful transform is not proof of compatibility with your application.
Frequently Asked Questions
sql-formatter 15.6.12 formats the selected SQL, MySQL, PostgreSQL or SQLite syntax with two or four spaces. Checked uppercase changes keywords; unchecked preserves their original case. Compact mode uses a separate lexical scanner: quoted strings and identifiers, comments and hints stay intact. Horizontal whitespace is reduced, but original separating newlines remain, including PostgreSQL adjacent string literals.
MySQL assumes default backslash escapes, without ANSI_QUOTES or NO_BACKSLASH_ESCAPES modelling. Unterminated tokens and DELIMITER directives are rejected. Queries are never executed; formatting does not validate tables, optimize queries or support arbitrary stored procedures.