---
title: "SQL Formatter for MySQL, PostgreSQL and More | ToolSugar"
description: "Indent and tidy SQL in your browser. Pick a dialect such as PostgreSQL, MySQL or SQL Server, and choose upper, lower or unchanged keyword case."
canonical: https://toolsugar.com/tools/sql-formatter
image: https://toolsugar.com/og.png
---

# SQL Formatter

This SQL formatter rewrites a query with one clause per line and consistent indentation, using the sql-formatter library in your browser. Choose a dialect such as PostgreSQL, MySQL, SQLite, SQL Server, Oracle, BigQuery or Snowflake, and set keywords to upper, lower or unchanged case. Your SQL is never uploaded.

Runs on your device

## How it works

1. Paste your query into the SQL box, or open a .sql file.
2. Pick a Dialect that matches your database.
3. Choose UPPER, lower or Keep as typed under Keyword case.
4. Copy the formatted SQL or press Download to save formatted.sql.

## Key facts

- **Where it runs**: In your browser tab. The text and files you use are never uploaded.
- **Live result**: The output updates as you type or paste, with no button to press.
- **Dialects**: Standard SQL, PostgreSQL, MySQL, MariaDB, SQLite, SQL Server, Oracle PL/SQL, BigQuery and Snowflake.
- **Indent**: Two spaces per level. Comments in the query are kept.

## Common uses

- Making a one line query from a log readable in a code review.
- Applying the same keyword case across a team's queries.
- Checking the structure of a generated ORM query.

## Questions

### Is my data sent to a server?

No. The conversion runs in your browser with JavaScript, so what you paste or open stays on your device. You can switch off your network after the page loads and it keeps working.

### Does formatting change what my query does?

It only changes whitespace and keyword case. Identifiers, string literals and values are left as written.

### Why does it show an error for my SQL?

The formatter has to tokenize the query, and a dialect it does not expect can fail. Try another dialect that matches your database, and check for an unclosed quote or bracket.

[Read the SQL Formatter guide](https://toolsugar.com/blog/how-to-format-sql)

## Related tools

- [JSON Formatter](https://toolsugar.com/tools/json-formatter)
- [CSV to JSON](https://toolsugar.com/tools/csv-to-json)
- [JSON to CSV](https://toolsugar.com/tools/json-to-csv)
- [XML to JSON](https://toolsugar.com/tools/xml-to-json)
