SQL Formatter

Break a long query into lines you can actually review, with keywords in upper or lower case and the indentation you prefer.

SQL Formatter

Developer Tools

Runs locally in your browser.

Runs locally in your browser — your SQL never leaves your device.

About the SQL Formatter

Raw SQL queries pulled from application logs, ORM (Object-Relational Mapping) consoles, or database dump files often take the form of large, single-line strings. Such queries are generally challenging to read, parse, and reason about. At the same time, pasting such queries in foreign online services is generally a privacy nightmare, as the query contains database schema information and potentially sensitive data. The SQL Formatter addresses both these concerns: it can beautify SQL query strings, transforming them into much more readable form. It also takes privacy and local processing very seriously – there are even two security-related notes in the app’s interface reminding the user that it all happens locally.

Key Features of SQL Formatter

  • Local privacy /100% secure/Your database queries are processed in the browser: this means you can trust us regarding the privacy of your data. The note about the local processing is right there in the app interface: your SQL never leaves your device.
  • Keyword case toggle/ SQL formatting/Use the “Keyword case” toggle to set your preferred styling for SQL keywords. Toggle the dropdown to select how you want your queries to be indented – e.g., to have 4 spaces per indent level.
  • Instant beautification/Paste the raw SQL query in the input field and click the “Format” button to instantly receive the pretty-printed version of the exact same query. There is even an option to copy the formatted query or download it as a .sql file for your convenience.

How to Use SQL Formatter

  1. Paste the SQL query you’d like to process into the “SQL input” field (see the “Sample” button for an example query). Pick your preferred capitalization style from the “Keyword case” dropdown. Pick your preferred indentation from the “Indent” dropdown. Click the “Format” button to see the resulting, beautified SQL query. You can copy or download the query using the buttons provided and clear the input using the “Clear” button.

SQL Formatter Examples

A query written on one line, split by clause so the conditions are easier to review. Formatting does not check the query against a database.

Input
select id, name from users where active = 1 and city = 'Rabat' order by name limit 10
Result
SELECT id,
name
FROM users
WHERE active = 1 AND city = 'Rabat'
ORDER BY name
LIMIT 10

SQL Formatter — Frequently Asked Questions

Why do I need to format my SQL queries?
Formatting your SQL makes it more readable and understandable. By formatting the query, you make it easier to grasp it as a whole and spot individual parts of it. The query breakdown helps you analyze what database records are accessed and how the query could be optimized. It also helps you review the code to look for possible issues.
Isn’t this tool unsafe for queries with sensitive data?
This SQL Formatter is secure because all processing happens locally in the browser; your data never leaves your device. This tool does not have a backend server to which your confidential data could be sent. Thus, the tool is safe to use with sensitive data.
What does the “Keyword case” toggle do exactly?
SQL is a case-insensitive language: it does not matter whether SQL keywords and identifiers are written in uppercase, lowercase, or mixed: SELECT, select, SeLeCt – all are the same for the database. However, it is common practice to write SQL keywords in uppercase and database identifiers in lowercase. The keyword case toggle lets you apply this common style to your SQL queries.