🗃️

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:

Options

Input (Bytes)
Output (Bytes)
Input / Output (Lines)

Lines:

Dependency licenses

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.

Embed this tool on your website

Use whole pixel dimensions from 1 to 4096.

× px (1–4096)

                        

💡 Integration Tip

Copy the embed code and paste it into your website HTML. The responsive version adapts to all screen sizes automatically.

3.3
6 ratings
✓

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

Developers and QA engineers inspecting, validating, or transforming data using the SQL Formatter.
DevOps practitioners debugging configuration files, tokens, or API responses on the fly.
Students learning web development, data formats, or encoding schemes with a hands-on SQL Formatter.
Technical writers preparing code samples, configuration examples, or documentation assets.
Security researchers and bug bounty hunters who need a quick sandbox without CLI access.

How to use

1

Paste SQL into “Input”, or use “Load sample” to load an example.

2

Choose “Dialect”, paste SQL, then use “Format” or “Compact”. Input or option changes require another action.

3

Check “Uppercase keywords” to uppercase SELECT, FROM, JOIN and WHERE; uncheck it to preserve keyword case.

4

Select 2 or 4 spaces in “Indent”; this and “Uppercase keywords” affect “Format” only.

5

Read “Output” and compare the “Lines” counts.

6

Use “Copy” for the clipboard or “Download” to save query.sql.

7

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.

Popular Tools

No more tools to show
Explore All Tools
FreeWebTools AI