JSQLFormatter
JSQLFormatter is a platform-independent SQL formatter, beautifier, and pretty printer.
What JSQLFormatter is
JSQLFormatter is a platform-independent SQL formatter, beautifier, and pretty printer. It parses SQL into an abstract syntax tree using a grammar, then formats supported statements while retaining comments and leaving comment-like text inside string literals unchanged. Supported statements include SELECT, INSERT, MERGE, UPDATE, DELETE, CREATE, and ALTER, including WITH clauses and nested sub-selects. Listed database dialects span Oracle, SQL Server, MySQL, MariaDB, PostgreSQL, H2, DuckDB, BigQuery, Redshift, Databricks, and Snowflake. Formatting settings cover indentation, comma placement, and the casing of keywords, functions, and objects, and can be set per invocation, file, or statement. Output options include ANSI terminal highlighting and HTML or RTF. A Java source feature imports SQL strings while preserving variables and can export them as String, StringBuilder, or MessageFormat. It is available as a Java library JAR from Maven Central and an executable JAR for command-line use. JSQLFormatter is free and open source under Apache 2.0 from version 5.4 onward; releases through version 5.3 used AGPL. A NetBeans plugin is a platform target, while several other IDE integrations are listed as planned.
Good
- Parses SQL with a grammar into an abstract syntax tree
- Supports a wide range of listed SQL dialects
- Preserves comments and ignores comment-like string literals
- Available as a Java library and command-line JAR
Watch out
- IDE integrations beyond NetBeans are listed as planned
- Native dynamic libraries are marked coming soon
- Licensing differs for releases through version 5.3
Who it suits
JSQLFormatter suits developers who want configurable SQL formatting in Java library or command-line workflows. Its dialect coverage and preservation of comments may also help people working with varied SQL sources.
Verdict
JSQLFormatter offers configurable formatting, broad listed dialect coverage, and both library and CLI forms. Check its version-specific license and planned-versus-available integrations against your needs.
Plans and prices
From JSQLFormatter's own pricing page, checked 4 Oct 2001.
| Plan | Price | What it gives you |
|---|---|---|
| JSQLFormatter | Free | Apache 2.0 licensed from version 5.4; available as Java library and command-line executable |
The facts
Each one read from JSQLFormatter's own pages, with the date it was checked.
What it does
- Comments
- It preserves comments, including comments between keywords or inside join conditions, and leaves comment-like string literals alone.checked 4 Oct 2001
- Configuration
- Indent width, comma placement, and keyword, function and object casing can be configured per invocation, file or statement.checked 4 Oct 2001
- Database coverage
- The site lists Oracle, SQL Server, MySQL, MariaDB, PostgreSQL, H2, DuckDB, BigQuery, Redshift, Databricks and Snowflake.checked 4 Oct 2001
- IDE integrations
- The site says a NetBeans plugin is a platform target and lists Eclipse, JEdit, Squirrel SQL and DBeaver as planned.checked 4 Oct 2001
- Interfaces
- The product is offered as a Java library JAR from Maven Central and as an executable JAR for command-line use.checked 4 Oct 2001
- Java source
- It can import SQL strings from Java source while preserving variables and export them as String, StringBuilder or MessageFormat.checked 4 Oct 2001
- License
- JSQLFormatter is licensed under Apache 2.0 from version 5.4 onwards; releases through 5.3 were AGPL.checked 4 Oct 2001
- Native libraries
- The installation page labels native dynamic libraries as “Coming soon.”checked 4 Oct 2001
- Output formats
- It supports ANSI terminal highlighting and HTML and RTF output for documents and wikis.checked 4 Oct 2001
- Parsing
- It parses SQL into an abstract syntax tree using a real grammar rather than regular expressions.checked 4 Oct 2001
- Purpose
- JSQLFormatter is a platform independent SQL formatter, beautifier and pretty printer.checked 4 Oct 2001
- Security and privacy
- The product page describes local Java and command-line use but does not state a security certification or compliance claim.checked 4 Oct 2001
- Statement coverage
- It supports SELECT, INSERT, MERGE, UPDATE, DELETE, CREATE and ALTER statements, including WITH clauses and nested sub-selects.checked 4 Oct 2001
The company
- Founded
- 2011checked 28 Sep 2001
- Maker
- Manticore Projects describes itself as a consulting company for financial valuation, reporting and credit risk management.checked 4 Oct 2001
Alternatives to JSQLFormatter
- 1
Poor SQL
Free planOpen sourceWebAPIExtensionLinux7.3Free plan - 2
SQLFormat.org
Free planOpen sourceWebAPIExtensionSelf-hosted7.1Free plan - 3
sqlfmt
Free planWebAPILinuxSelf-hosted6.7Free plan - 4
RegSQL
Free planWeb6.5From $8 a month - 5
SQLCheck
Free planLinuxmacOSWindows6.5Free plan - 6
sqlfmt
Free planWebAPI6.5From $9 a month
