SQL Formatter
Paste an unformatted SQL query and get an indented, readable version, with support for several SQL dialects (MySQL, PostgreSQL, SQLite, MariaDB, BigQuery, and SQL Server). All processing happens in your browser with the sql-formatter library.
How it works
- Paste or type your SQL query into the input panel.
- Choose the SQL dialect that matches your database, since each one has slightly different syntax.
- Choose the indentation size (2 or 4 spaces).
- The formatted result is generated instantly, with keywords in uppercase and a clear structure by clause.
- Copy the result or download it as a .sql file.
Use cases
- Clean up SQL queries generated by ORMs or tools that output them on a single line.
- Review and debug complex queries with multiple JOINs, subqueries, or conditions.
- Prepare readable SQL to share in documentation, code reviews, or tickets.
- Standardize a team's SQL query style before committing it to the repository.
Common mistakes
- No elegir el dialecto correcto para tu motor de base de datos.Cada motor (MySQL, PostgreSQL, SQL Server, etc.) tiene particularidades de sintaxis; elegir el dialecto correcto mejora cómo se interpreta y formatea la consulta.
- Pegar varias sentencias separadas por ; esperando que cada una se formatee de forma aislada.La herramienta puede formatear múltiples sentencias, pero revisá que cada una termine correctamente con ; para evitar resultados inesperados.
- Confundir un error de formateo con un error real de la base de datos.Esta herramienta solo analiza la sintaxis para reformatear el texto; no ejecuta la consulta ni verifica que las tablas o columnas existan.
Frequently asked questions
Alternatives
Extensiones de editor como SQL Formatter para VS Code hacen algo similar dentro de tu IDE. Esta herramienta es útil para formatear rápido una consulta pegada desde un log, un chat o un ticket, sin abrir el editor.