A Go library and CLI that parses ClickHouse-dialect SQL into a typed AST and formats or beautifies queries.
JSQLParser/JSqlParser
A Java SQL parser that turns SQL statements into a traversable tree of Java objects and can render them back to SQL text.
- Stars
- 5,975
- Forks
- 1,446
- Open issues
- 8
- Last commit
- 2 days ago
What is it?
JSqlParser parses an SQL statement into a hierarchy of Java classes that can be navigated with the Visitor pattern, rewritten, and printed back as SQL. It is RDBMS-agnostic: one grammar covers dialects such as MySQL, PostgreSQL, Oracle, SQL Server, BigQuery, Snowflake, DuckDB and SQLite, with dialect options for edge cases.
Beyond parsing, the project can classify a statement by whether it returns rows or modifies data, which helps build read-only guards or choose between query and update execution. Statements can also be built from Java with a fluent API and serialized to SQL text. Piped SQL syntax is in progress.
It requires a JDK 11 runtime and is distributed through Maven Central, with the actively maintained Manticore builds recommended over the older upstream release.
Key features
- 01Parses SQL into a Java object tree that can be traversed with the Visitor pattern
- 02Converts the object model back into SQL text
- 03Covers many dialects including MySQL, PostgreSQL, Oracle, SQL Server and BigQuery
- 04Classifies statements by whether they return rows or modify data
- 05Builds SQL statements from Java with a fluent API
Use cases
- Rewriting or auditing SQL queries in a Java application before execution
- Blocking data-modifying statements on read-only database connections
- Extracting tables and columns referenced by a query for analysis or lineage tooling
- Generating SQL programmatically from Java code
Quick start
- 1
Add the Manticore build dependency to your Maven pom.xml
- 2
Parse a SQL statement with CCJSqlParserUtil.parse and walk the resulting tree
Things to know
- Building from source requires a JDK 17 toolchain.
- The README recommends Manticore builds because the upstream Maven Central release is considerably older.
In collections
Topics
FAQ
- What is JSqlParser?
- A Java SQL parser that turns SQL statements into a traversable tree of Java objects and can render them back to SQL text. JSqlParser parses an SQL statement into a hierarchy of Java classes that can be navigated with the Visitor pattern, rewritten, and printed back as SQL. It is RDBMS-agnostic: one grammar covers dialects such as MySQL, PostgreSQL, Oracle, SQL Server, BigQuery, Snowflake, DuckDB and SQLite, with dialect options for edge cases.
- Is JSqlParser free to use? What license does it have?
- JSqlParser is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
- Is JSqlParser still maintained?
- Actively maintained. The last commit to JSqlParser was on Nov 5, 2026.
- What can I use JSqlParser for?
- Rewriting or auditing SQL queries in a Java application before execution Blocking data-modifying statements on read-only database connections Extracting tables and columns referenced by a query for analysis or lineage tooling Generating SQL programmatically from Java code
- How do I install JSqlParser?
- Add the Manticore build dependency to your Maven pom.xml Parse a SQL statement with CCJSqlParserUtil.parse and walk the resulting tree
- Where can I get JSqlParser?
- The source code and installation instructions are on GitHub: https://github.com/JSQLParser/JSqlParser
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
Free browser-based database schema editor that draws ER diagrams and generates SQL scripts, with no account required.
A free, open source native database client for macOS and iOS supporting SQL and NoSQL databases, with built-in AI chat and an MCP server.
A terminal (TUI) database client for PostgreSQL, MySQL, SQLite, DuckDB and more, with vim-style keybindings.
Native database IDE for macOS, Windows and Linux supporting PostgreSQL, MySQL, SQLite, Redis, MongoDB, SQL Server and ClickHouse, with a built-in MCP server and AI chat.
AI-powered database client and MCP server for desktop and web, supporting Postgres, MySQL, MariaDB, SQL Server, ClickHouse and SQLite.