SQL Formatter

Format and beautify SQL queries with configurable indentation and keyword casing.

POST 1 credit /v1/sql-format
curl -X POST "https://devtools.toolkitapi.io/v1/sql-format" \
  -H "Content-Type: application/json" \
  -d '{"sql": "select id,name from users where active=1 order by name", "indent": 2, "uppercase": true}'
import httpx

resp = httpx.post(
    "https://devtools.toolkitapi.io/v1/sql-format",
    json={"sql": "select id,name from users where active=1 order by name", "indent": 2, "uppercase": true},
)
print(resp.json())
const resp = await fetch("https://devtools.toolkitapi.io/v1/sql-format", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"sql": "select id,name from users where active=1 order by name", "indent": 2, "uppercase": true}),
});
const data = await resp.json();
console.log(data);
# See curl example
Response 200 OK
{
  "formatted": "SELECT id,\n       name\nFROM users\nWHERE active = 1\nORDER BY name"
}

Try It Live

Live Demo

Description

Format and beautify SQL queries with configurable indentation and keyword casing.

How to Use

1

1. Send a POST request with the `sql` field containing your query.

2

2. Optionally set `indent` for indentation width and `uppercase` for keyword casing.

About This Tool

SQL Formatter takes raw SQL queries and outputs clean, consistently indented SQL. Configure indentation width and choose uppercase or lowercase keywords.

Why Use This Tool

Frequently Asked Questions

Which SQL dialects are supported?
The formatter uses `sqlparse` which handles standard SQL syntax. It works with MySQL, PostgreSQL, SQLite, and most SQL dialects for formatting purposes.
Does it validate SQL syntax?
No. The formatter only reformats the text — it does not parse or validate SQL semantics.

Start using SQL Formatter now

Get your free API key and make your first request in under a minute.