--- id: sql-formatter version: "0.6.2" license: Apache Software License 2.0 license_treatment: permissive maintenance: abandoned --- # sql-formatter — A SQL formatter License: permissive · Maintenance: abandoned · Downloads: 854.6K/mo ## What it is and what it does sql-formatter is a Python-based command-line and library tool that reformats SQL queries into a standardized, readable layout. It uses indentation and case normalization (uppercasing keywords, lowercasing identifiers) to enhance readability and make query structure immediately apparent. The formatter handles SELECT and CREATE TABLE/VIEW statements, including subqueries and joins, and can be invoked from the command line on individual files or batches, integrated into pre-commit hooks, or called directly from Python code. The package includes basic validation to catch common mistakes like forgotten semicolons, unbalanced parentheses, and mismatched CASE/WHEN/END blocks. It does not parse SQL into data structures, validate queries against a specific database system, or format other SQL commands like INSERT or UPDATE. The project is no longer actively maintained as of April 2022, so it may not reflect current SQL standards or work seamlessly with the latest Python versions. Use it for: - Format SQL files in a pre-commit hook to enforce consistent styling across a team's repository. - Reformat ad-hoc or poorly formatted SQL queries in Python scripts to improve readability before review or deployment. - Batch-process a directory of SQL files to standardize indentation and keyword casing across a legacy codebase. - Integrate into a data pipeline to normalize query formatting for logging or audit purposes. - Use as a command-line tool to quickly beautify SQL files during development without leaving the terminal. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Reformats SQL queries into standardized, readable form with consistent indentation, capitalization, and line breaks, handling SELECT and CREATE statements with subqueries. Yes, if you need a lightweight, dependency-free SQL formatter for SELECT and CREATE statements and can tolerate an unmaintained codebase. The permissive Apache license and zero runtime dependencies make it low-friction to add. However, do not rely on it for production systems handling modern SQL dialects or requiring ongoing support—test thoroughly with your SQL patterns first, and consider alternatives if you need active maintenance or broader SQL command support. ## Install pip install sql-formatter uv add sql-formatter poetry add sql-formatter ## Installing sql-formatter Before you install: No runtime dependencies and a pure-Python wheel distribution make installation straightforward. However, the project has been abandoned since April 2022 with no updates for nearly two years, so maintenance and compatibility with newer Python versions or SQL dialects is not guaranteed. License in practice: Licensed under Apache Software License 2.0 (permissive), so you may use, modify, and distribute the package freely in both open-source and commercial projects with minimal restrictions. Quickstart: pip install sql-formatter from sql_formatter.core import format_sql formatted = format_sql("select a, b from table1 where a = 1") print(formatted) Requires Python 3.6 or later. SQL statements must end with a semicolon for the formatter to work correctly. Verify before relying: - Whether the formatter handles modern SQL dialects (PostgreSQL, BigQuery, Snowflake, etc.) or only generic SQL syntax. - Whether the package works reliably with Python versions newer than 3.8, given the abandonment status. - Performance characteristics when formatting very large SQL files or deeply nested subqueries. ## Package facts - License: Apache Software License 2.0 (permissive) - Python support: supports_current - Install friction: low - Maintenance: abandoned - Downloads: 854.6K/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags sql formatting tool, sql query beautifier, sql code formatter, standardize sql syntax, sql readability tool, format sql files, sql indentation, sql-formatting, code-style, cli-tool [View on SkillFed](https://skillfed.io/packages/sql-formatter) · [View on PyPI](https://pypi.org/project/sql-formatter/)