JSON Formatter
Format, pretty-print, and validate JSON in your browser.
Format SQL queries for readability.
SQL Formatter reformats poorly indented or single-line SQL queries into a clean, readable structure with proper line breaks and indentation. It helps with code reviews and debugging complex queries that involve JOINs and subqueries. It supports major SQL dialects such as MySQL, PostgreSQL, and SQLite, and lets you configure indent width and keyword casing.
SELECT, FROM, WHERE, JOIN, and so on) is broken onto its own line and indented, making it easy to see which tables are joined on which conditions.Input (single-line SQL):
select u.id, u.name, o.total from users u join orders o on u.id = o.user_id where o.total > 100 order by o.total desc
Formatted (2-space indent, uppercase keywords):
SELECT
u.id,
u.name,
o.total
FROM
users u
JOIN orders o ON u.id = o.user_id
WHERE
o.total > 100
ORDER BY
o.total DESC
Each clause — SELECT, FROM, JOIN, WHERE, ORDER BY — starts on its own line, with selected columns and join conditions indented underneath, so you can quickly grasp the shape of the whole query.
Setting “Indent” to “Tab” reformats the same input using tab characters instead of spaces — handy when you want the output to match your editor’s tab-width setting.
SELECT
u.id,
u.name
FROM
users u
Input:
SELECT id, name FROM users WHERE active = TRUE
Setting “Keyword case” to “Lowercase” normalizes SELECT, FROM, and other keywords to lowercase:
select
id,
name
from
users
where
active = true
Choosing “Preserve” leaves the original keyword casing (including any mixed case) exactly as typed.
Consider a query using MySQL-style backtick-quoted identifiers:
SELECT `user`.`id`, `user`.`name` FROM `user` WHERE `user`.`status` = 1
With the Dialect set to “MySQL” or “MariaDB” this formats without issue. With “Standard SQL” selected, backticks aren’t a recognized identifier quoting style and formatting can fail with an error. Matching the Dialect to your actual database lets you catch this kind of dialect-specific syntax difference early.
Standard SQL, MySQL, PostgreSQL, SQLite, T-SQL (SQL Server), PL/SQL, and MariaDB.
Yes. Set the "Keyword case" option to "Uppercase" to normalize SELECT, FROM, and other keywords. Choose "Lowercase" to lowercase them instead, or "Preserve" to keep the casing as typed.
No. All processing happens in your browser. The contents of your query are never sent anywhere.
Turning on "Auto-format" reformats the query automatically every time you edit the input, so you don't need to click "Format" each time.
Yes. Drop a .sql or .txt file (under 5MB) onto the input field and its contents are loaded automatically.
Yes. Press Ctrl+Enter (⌘+Enter on Mac) to format, and Ctrl+Shift+C (⌘+Shift+C on Mac) to copy the result.