Skip to content
Toolars
Explore

SQL Formatter

Format or compact SQL across seven dialects — PostgreSQL, MySQL, SQL Server, and more — in a local Worker, without connecting to a database.

Task path / input to outcome

Choose the SQL dialect

Report bug

Local processing

Processing details

Tool inputs are processed on your device.

Resources may be downloaded to run this tool. Account services are separate.

Preparing offline use…

Privacy information

Task path / input to outcome

How to format SQL without executing it

  1. 01

    Choose the SQL dialect

    Select Standard SQL, PostgreSQL, MySQL, SQLite, SQL Server, BigQuery, or Snowflake so dialect-specific syntax is tokenized correctly — PostgreSQL is the default. There is no autodetection: pick the dialect your database actually speaks, because a clause that formats cleanly under Standard SQL can read differently once the correct dialect owns the keywords.

  2. 02

    Paste and format immediately

    Paste or type up to 256 KiB of SQL. A paste runs at once, ordinary edits re-run after a short pause while Auto-format is on, and Ctrl or Command plus Enter applies the current options on demand. The workspace opens with a sample join query, so you can watch the formatter work before trusting it with production SQL.

  3. 03

    Choose readable or compact output

    Compact preserves line breaks, comments, literals and token separators. PostgreSQL assumes standard_conforming_strings=on; MySQL assumes default backslash escaping. Database session modes are not detected. Formatting would change quoted content, comments or literal line boundaries. Try Compact mode or adjust the SQL; no partial result is exported.

  4. 04

    Check the result and byte counts

    The output pane updates with each run, and the footer reports the exact input and output byte counts so the cost of readability — or the savings from compacting — is visible. Runs execute in a Web Worker with a reviewed 1,500 ms budget, formatted output is capped at 512 KiB, and a statement the tokenizer cannot handle stops with its line and column named.

  5. 05

    Review, copy, or download

    Review the result against your database version, then copy it to the clipboard or download it as toolars-formatted.sql. Formatting does not replace database validation: the workspace never connects to a database, so confirm object names, permissions, and semantics where the query will actually run. Cancel stops the current run and turns off Auto-format while keeping SQL. Editing SQL or options clears the previous output.

Tool facts

Processing
In your browser
Input leaves this device
Never
Retention
Nothing is stored
Price
Free

Your input stays in the browser.

SQL Formatter uses its verified local execution path and does not create a hidden input or output history.

Local execution

Runs inside the current browser tab.

No hidden processing

Active tool data never becomes a Toolars document record.

No account required

Use the core workflow without creating a profile. Favorites sync to your account after you sign in.

Immediate reset

Clear the tab and the active working data is gone.

What SQL Formatter actually does

A 40 KB query arrives from an application log as one dense line and must be readable before the pull request review. Choose PostgreSQL, keep the default Upper keyword case and two-space indent, and the formatted statement lands in the output pane before you reach for the mouse — the footer confirms exactly how many bytes the readability cost. Later, when the migration tool wants the same statement packed tightly, switch to Compact: whitespace collapses while the quoted literals and the commented-out clause survive untouched. No database connection is opened at any point, and the log extract never leaves the tab.

Common questions

Which SQL dialects are supported?
Standard SQL, PostgreSQL, MySQL, SQLite, SQL Server, BigQuery, and Snowflake are available in this release. Choose the dialect explicitly for the most reliable formatting — the workspace never guesses, because keyword sets and identifier quoting differ between dialects and a wrong guess would reshape the statement incorrectly.
Does Toolars execute or fully validate SQL?
No. The workspace never connects to a database or executes a query. Formatting checks whether the selected formatter can tokenize the input, not whether schemas, permissions, types, or query semantics are valid — a statement can format beautifully and still fail at the database, which is exactly where final validation belongs.
What is the difference between Format and Compact?
Compact preserves line breaks, comments, literals and token separators.
What are the size limits?
One run accepts up to 256 KiB of SQL and produces at most 512 KiB of formatted output, which matters because indentation can grow a dense statement substantially. Each run also gets a reviewed 1,500 ms execution budget inside its Worker; a run that exceeds it is stopped and reported rather than allowed to stall the page. Larger scripts can be split into individual statements and processed in batches.
Why did formatting fail with an error?
The most common causes are an unterminated string, quoted identifier, dollar-quoted block, or comment — the error names the line and column where the token opened — and syntax the chosen dialect's tokenizer cannot handle, which the formatter reports with its parser position when available. Check the flagged spot first, and try Compact mode while debugging: it applies no dialect grammar, so it shows whether the problem is lexical or dialect-specific.
Is my SQL uploaded or stored?
No. SQL input, output, errors, clipboard values, and downloads stay in the browser and are not placed in URLs, storage, analytics, logs, or feedback payloads. Clearing the workspace discards the current statement.

Related tasks, not a dead end.

Move into another focused workspace without returning to the full index.

URL Workbench

Clean URL lists with signed-link protection and per-line reasons. Compare components and export sitemaps.

Edit

JSON Explorer

Query JSONPath, extract fields and round-trip JSON Pointer records without losing large-number precision.

Inspect

JSON Schema Validator

Validate Draft 7 or 2020-12 locally with exact error paths; infer schemas from multiple observed samples.

Inspect

HTML Publishing

Clean pasted HTML for publishing while preserving lists, links and table semantics; preview changes safely.

Publish