Formateador SQL
Formatea consultas SQL con indentación consistente, case de palabras clave y saltos de línea. Multidioma.
Respuesta rápida: Formateador SQL: da formato a consultas SQL con sangría uniforme, uso coherente de mayúsculas en palabras clave y saltos de línea. Compatible con varios dialectos. Funciona por completo en el navegador, gratis y sin registro.
Última actualización
Bueno saber
Consistent SQL formatting is more than aesthetics — a query with keywords aligned and clauses on their own lines is dramatically easier to review, and it produces cleaner version-control diffs so a reviewer sees the one predicate that changed rather than a reflowed wall of text. The formatter only rearranges whitespace and keyword case; it never alters the logic, so a formatted query returns exactly the same rows as the original.
Picking the right dialect matters for accuracy. Postgres, MySQL, T-SQL, BigQuery, and Snowflake each have keywords and functions the others don't (ILIKE, QUALIFY, MERGE, backtick quoting), and choosing the closest match lets the parser recognize them and lay them out correctly instead of treating them as bare identifiers. Feed it CTEs, window functions, and recursive queries and it will indent the nesting sensibly.
One prerequisite: the input needs to be syntactically valid. A missing comma or unclosed parenthesis can leave the formatter unable to indent gracefully, so if the output looks mangled, the real fix is usually a syntax error upstream rather than a formatter setting.
Formatting is a read-time convenience — it runs entirely in your browser, so even queries that touch sensitive schemas are safe to paste. When you need to compare two versions of a query or a result payload rather than reformat one, the JSON diff tool pairs well for the data side.
Preguntas frecuentes
- ¿Romperá el formateador mi consulta?
- No — el formateo solo cambia el espacio en blanco y el caso de las palabras clave. La semántica de la consulta es idéntica a la entrada. La excepción: si tienes errores de sintaxis, el formateador puede que no pueda indentar de forma adecuada.
- ¿Qué dialectos son compatibles?
- SQL estándar, PostgreSQL, MySQL, MariaDB, SQLite, BigQuery, Snowflake, Redshift y T-SQL (SQL Server). Elige la opción más cercana para el reconocimiento más preciso de palabras clave.
- ¿Puedo mantener las palabras clave en minúsculas?
- Por defecto usamos MAYÚSCULAS porque es la convención dominante; futuras versiones mostrarán un conmutador. Por ahora, puedes cambiar manualmente a minúsculas después de formatear.
- ¿Se suben mis consultas?
- No — el formateo se ejecuta completamente en tu navegador. Nada sale de tu dispositivo.
- ¿Formateará CTEs y funciones de ventana?
- Sí — las expresiones de tabla comunes, las funciones de ventana, las CTEs recursivas y los procedimientos almacenados se formatean de manera limpia.