JSqlParser 5.3: A Java AST for SQL, with a Faster Fork and a Dialect Catch-All
JSqlParser parses an SQL statement and translate it into a hierarchy of Java classes. The generated hierarchy can be navigated using the Visitor Pattern.
At a glance
- What is it?
- JSqlParser turns SQL into a traversable Java object tree and back. The 5.3 release is a major speedup, but the README's own install advice points at a fork, not the upstream artifact.
- Who is it for?
- Adopt JSqlParser if you need a Java-friendly SQL AST for parsing, rewriting, or generating SQL across many dialects, and you can tolerate the grammar's 'add on demand' approach to new syntax. Do not adopt it if you need a stable, vendor-certified parser for a single dialect, or if you must stay on JDK 8 (4.9 is the last such release).
- Can I use it commercially?
- Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 2 days ago.
- What is it written in?
- Mainly Java, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on September 15, 2026, and from our analysis. They are not legal advice.
DEEP OPEN-SOURCE ANALYSIS
What JSqlParser Solves and Who Needs It
JSqlParser addresses a recurring problem for Java developers: turning SQL text into a structured object model that can be inspected, modified, and rendered back as SQL. The README's example shows a simple SELECT becoming a PlainSelect object with getters for select items, the FROM table, and the WHERE clause. This is useful for tooling that must understand SQL without executing it: query analyzers, schema diff tools, data lineage systems, or any application that needs to rewrite user-supplied SQL. The intended audience is JVM developers building such tools, not database drivers or query engines. The parser is RDBMS-agnostic, aiming to cover the SQL standard plus a dozen dialects, which is a different niche than a database-specific parser that guarantees exact syntax support. If your project only needs to parse one dialect and you rarely see new syntax, a hand-written parser might be simpler, but JSqlParser's value is in breadth: one grammar for BigQuery, Snowflake, DuckDB, Redshift, Oracle, SQL Server, PostgreSQL, MySQL, and others. The README claims it handles nested sub-selects, bind parameters, window functions, Oracle hints, and the T-SQL square-bracket ambiguity. That breadth is the core selling point, and it is also the source of its main weakness, which we will get to.
The Visitor Pattern and the Object Model
The parser's output is a hierarchy of Java classes that you navigate with the Visitor pattern. The README's tree diagram shows a SELECT statement with select items, a table, and a where clause, each represented by a distinct class like LongValue, Table, and EqualsTo. This is not a generic map or a list of tokens; it is a typed AST. The same object model works in reverse: you can build statements using a fluent API and render them as SQL text. That bidirectional capability is important. It means you can parse a query, modify the AST nodes, and print the result, which is the foundation for SQL rewriting tools. The visitor pattern is a deliberate choice: it lets you write traversal logic without scattering switch statements over every node type. However, it also means that adding a new SQL construct requires adding new visitor methods, which is a breaking change. The README notes that version 5.0 introduced breaking changes to the AST Visitors, so the API is not stable across major versions. If you maintain a tool that depends on a specific visitor interface, upgrading JSqlParser can be a significant effort. The object model is the heart of the library, and its design is a trade-off between type safety and evolvability.
Getting It Running: Two Coordinate Sets and a Version Range
Installing JSqlParser is straightforward, but the README introduces a confusing twist. The recommended dependency uses the Manticore group ID: com.manticore-projects.jsqlformatter:jsqlparser with a version range of [5.3.218,). The README calls these 'stable Manticore builds' and says they are released continuously from the current development line, carrying all the performance and grammar work. In contrast, the upstream artifact is com.github.jsqlparser:jsqlparser version 5.3, which the README describes as 'considerably older' and only hides behind a collapsible details tag. This is a significant decision point for adopters. If you follow the README, you are not using the upstream release; you are using a fork that is published under a different group ID. That has implications for trust and maintenance. The Manticore build uses a version range, which in Maven is a floating dependency that can pick up new releases automatically. That is convenient but risky: you might get a new grammar change that breaks your parsing without a deliberate upgrade. The upstream version is a fixed 5.3. The README also lists a Java version table: 4.9 is the last JDK 8 release, 5.0 and later require JDK 11, and building from source requires a JDK 17 toolchain for 5.1 and later. For a library, the runtime requirement matters more than the build requirement, but both are constraints. If you are on JDK 8, you are stuck with 4.9, which is an older grammar.
Performance Claims and the Benchmark Caveat
The README makes a bold performance claim: the latest development line is 11 times faster than version 5.3, and it calls JSqlParser 'the fastest parser on real-world SQL of any of the parsers tested, in any language.' The benchmark table shows 7.602 ms/op for the latest version versus 84.687 ms/op for 5.3. Those numbers come from a separate repository, jsqlparser-bench, which the README links to. I have not run those benchmarks, and the README does not describe the hardware, the SQL corpus, or the exact methodology beyond saying it compares against SQLGlot, sqlglot[c], and polyglot-sql. The claim that it is faster than any parser in any language is extraordinary and should be treated with skepticism until you reproduce it on your own workload. The 11x improvement over 5.3 is plausible if the development line includes significant grammar optimizations, but the README does not explain what changed. For an adopter, the practical takeaway is this: if you are currently on 5.3 and you care about parse throughput, the Manticore build might be worth trying, but you should benchmark it against your own SQL patterns. The benchmark suite is public, so you can inspect it. Performance is a real factor for batch processing of large query logs, but for interactive use, the difference between 7 ms and 85 ms per statement is rarely noticeable.
Dialect Coverage and the 'Add on Demand' Grammar
JSqlParser's grammar is a single grammar that attempts to cover the SQL standard plus all major RDBMS dialects. The README lists fifteen dialects, from BigQuery to SQLite, and a statement table that includes SELECT, DML, DDL, PostgreSQL row-level security, and even Salesforce SOQL. That is an ambitious scope. The README explicitly says 'missing syntax gets added on demand' and points to the issue tracker. This is a double-edged sword. On the positive side, it means the parser is actively evolving and you can request support for a specific syntax. On the negative side, it means there is no guarantee that your dialect's obscure feature is covered out of the box. For example, Oracle hints and T-SQL square brackets are mentioned, but that does not mean every variant is supported. The 'one grammar' approach also creates ambiguity problems. The README mentions the T-SQL square-bracket versus array-literal ambiguity, which is a classic example: in SQL Server, [name] is an identifier, but in other dialects, square brackets can denote an array. The parser has to resolve that based on context, and it can get it wrong. For a tool that must parse arbitrary user SQL, this is a real risk. If your application only handles a narrow set of SQL, you will be fine. If you need to parse complex Oracle PL/SQL or PostgreSQL-specific constructs, you should test extensively. The README's promise of 'one grammar, twelve dialects' is a marketing simplification; the reality is a grammar that is always catching up.
Piped SQL and the Direction of the Project
A notable feature in development is Piped SQL support. The README shows an example that uses the pipe operator (|>) to write queries in execution order: FROM, WHERE, AGGREGATE, ORDER BY. This is a modern syntax from BigQuery and DuckDB, and JSqlParser is adding support for it. The README links to Google's research paper and the BigQuery and DuckDB documentation. This is a forward-looking addition, and it shows that the project is not just maintaining legacy dialect support but also tracking new SQL paradigms. For an adopter, this is a positive signal: the grammar is actively updated to handle new syntax. However, it also means the parser is in flux. The README says 'support is progressing,' which implies it is not complete. If you need to parse Piped SQL today, you might hit gaps. The project's direction seems to be toward broader dialect coverage and modern syntax, which is good for a general-purpose tool. The sister projects, JSQLFormatter and JSQLTranspiler, are built on top of JSqlParser, which suggests the parser is stable enough to serve as a foundation for production tools. But those are separate projects, and their existence does not guarantee JSqlParser's own maturity.
Licensing, Maintenance, and Upgrade Cost
JSqlParser is licensed under Apache-2.0, which is permissive and allows commercial use without requiring you to open-source your code. That is a low-license-risk choice for most organizations. The project is not archived, and the last push was in May 2025, so it is actively maintained. The release cadence shows 5.1 in January 2025, 5.2 in May 2025, and 5.3 in May 2025, which is a fast pace. That is good for bug fixes and grammar updates, but it also means the API can change quickly. The README's migration guide is mentioned for the 5.0 breaking changes, which suggests that upgrading between major versions requires manual work. If you are on 4.9 and want to move to 5.3, you will need to update your visitor implementations. The maintenance cost is not trivial: you need to track releases, test your SQL corpus against each new version, and potentially adjust your code for API changes. The README also highlights the fork situation: the Manticore build is the recommended one, but it is not the upstream. That creates a maintenance question: if the fork and the upstream diverge, which one do you trust for long-term support? The upstream has a longer history, but the fork is where the performance work is happening. Before adopting, you should check the fork's commit history and release notes to see if it is a sustainable project. The Apache-2.0 license gives you the freedom to fork it yourself if needed, but that is a last resort.
Editorial conclusion
Adopt JSqlParser if you need a Java-friendly SQL AST for parsing, rewriting, or generating SQL across many dialects, and you can tolerate the grammar's 'add on demand' approach to new syntax. Do not adopt it if you need a stable, vendor-certified parser for a single dialect, or if you must stay on JDK 8 (4.9 is the last such release). Before committing, verify which artifact you actually depend on: the README pushes the Manticore fork (com.manticore-projects.jsqlformatter) for performance, while the upstream com.github.jsqlparser 5.3 is what the release notes describe. Also check the migration guide for 5.0's breaking visitor changes if you are upgrading from 4.9. Test your specific SQL corpus against the parser's grammar, especially for T-SQL or Oracle syntax, because the single-grammar approach may not cover every edge case.
Community notes