DEV.co
Open-Source Databases · JSQLParser

JSqlParser

JSqlParser is a Java library that converts SQL statements into a navigable tree structure of Java objects. It supports major database systems (Oracle, PostgreSQL, MySQL, SQL Server, BigQuery, etc.) and can both parse existing SQL and generate new SQL programmatically.

Source: GitHub — github.com/JSQLParser/JSqlParser
6k
GitHub stars
1.4k
Forks
Java
Primary language
Apache-2.0
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
RepositoryJSQLParser/JSqlParser
OwnerJSQLParser
Primary languageJava
LicenseApache-2.0 — OSI-approved
Stars6k
Forks1.4k
Open issues88
Latest releasejsqlparser-5.3 (2025-05-17)
Last updated2026-04-12
Sourcehttps://github.com/JSQLParser/JSqlParser

What JSqlParser is

JSqlParser translates SQL statements into an Abstract Syntax Tree (AST) using the Visitor pattern for traversal. It uses JavaCC-based parsing and supports standard SQL plus dialect-specific features across multiple RDBMS. Version 5.3+ targets JDK11+ with recent performance optimizations via grammar refactoring.

Quickstart

Get the JSqlParser source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/JSQLParser/JSqlParser.gitcd JSqlParser# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

SQL Analysis and Transformation Tools

Parse SQL statements to extract metadata, validate syntax, or transform queries across database dialects. Useful for schema analysis tools, SQL formatters, or transpilers targeting specific RDBMS.

Query Validation in Data Integration Pipelines

Embed SQL parsing in ETL/ELT frameworks to validate user-supplied queries before execution, detect unsupported syntax, or rewrite for specific engines (e.g., Redshift, BigQuery).

SQL Lineage and Column-Level Provenance

Extract table and column dependencies from SELECT/INSERT/UPDATE statements for data governance, impact analysis, or lineage tracking in data warehouses.

Implementation considerations

  • Requires JDK11+ runtime; 5.1+ build requires JDK17 toolchain. Plan Java version upgrade before adoption.
  • AST visitor pattern usage requires familiarity with Visitor design pattern; plan developer onboarding for teams unfamiliar with this pattern.
  • Parser grammar is RDBMS-agnostic but produces a single canonical AST; dialect-specific rewrites (e.g., BigQuery → Redshift) require post-parse transformation via sister project JSQLTranspiler.
  • API breaking changes between major versions (e.g., 4.9 → 5.0); review migration guide when upgrading.
  • Performance regression history (5.2) suggests benchmarking against your typical SQL workload before production deployment; 5.3+ addresses known issues.

When to avoid it — and what to weigh

  • Real-time SQL Execution Required — JSqlParser is a parser only; it does not execute SQL or manage connections. If you need to run queries, use a JDBC driver or ORM framework instead.
  • JDK 8 Support Required — JSqlParser 5.0+ requires JDK11 minimum (5.1+ requires JDK17 for build tooling). Older projects locked on JDK8 must use the EOL JSqlParser-4.9.
  • Non-Standard or Proprietary SQL Dialects — While coverage is broad, obscure or newly-released RDBMS-specific syntax may not be supported. Requires community contribution or custom extension to the grammar.
  • High-Frequency, Ultra-Low-Latency Parsing — Though performance has improved in 5.3+, latency-critical applications (sub-millisecond parsing at scale) should benchmark against use case. Historical regressions (5.2) noted in changelog.

License & commercial use

Dual-licensed under LGPL V2.1 or Apache License 2.0 (Apache-2.0). The Apache-2.0 leg is permissive (OSI-approved) and suitable for most commercial use.

The Apache-2.0 license option permits commercial use, modification, and distribution with standard OSI permissive terms (attribution, liability disclaimer). However, the dual license structure with LGPL V2.1 as an alternative means licensees must select which license applies to their use. Review license choice with legal counsel if LGPL implications (copyleft on derivative library distributions) concern your scenario.

DEV.co evaluation signals

Editorial assessment — not user reviews. Directional, with an explicit confidence level.

SignalAssessment
MaintenanceActive
DocumentationStrong
License clarityClear
Deployment complexityLow
DEV.co fitStrong
Assessment confidenceHigh
Security considerations

JSqlParser performs syntactic parsing only and does not execute SQL, so injection risks are inherent to the host application's query execution layer, not the parser itself. However, applications must validate that parsed query trees conform to expected structure before execution (e.g., deny unexpected UDFs or schema-changing statements). No CVE history provided in data; treat as unknown until audit. Dependency on JavaCC compiler; keep toolchain updated.

Alternatives to consider

JOOQ (dual-licensed)

Handwritten parser with broader RDBMS support, SQL builder/DSL, dialect translation, and JDBC proxy integration. More heavyweight but integrates execution layer. Commercial support available.

Calcite (Apache)

Query optimizer and dialect translator; heavier weight and designed for data federation rather than lightweight parsing. Good if building query federation or optimization layer.

Native parsers for specific RDBMS often more complete for that dialect but lose RDBMS-agnostic portability.

Software development agency

Build on JSqlParser with DEV.co software developers

Need to analyze, validate, or transform SQL across multiple databases? JSqlParser provides a robust, actively maintained solution. Contact us to discuss how to integrate SQL parsing into your data infrastructure.

Talk to DEV.co

Related open-source tools

Surfaced by semantic similarity across the DEV.co open-source index.

Related on DEV.co

Explore the category and the services that help you build with it.

JSqlParser FAQ

Can JSqlParser execute SQL?
No. JSqlParser parses SQL text into an AST only. To execute, use a JDBC driver, ORM, or embedded database. This is by design for portability and security (parser has no database access).
Which Java versions are supported?
JSqlParser 5.0+ requires JDK11+ at runtime. JSqlParser 5.1+ requires JDK17 for building. Version 4.9 is the last JDK8-compatible release (EOL).
Does JSqlParser support my RDBMS's dialect?
Coverage includes BigQuery, Snowflake, DuckDB, Redshift, Oracle, SQL Server, Postgres, MySQL, DB2, H2, SQLite, and others. Check the syntax table at jsqlparser.github.io/JSqlParser/syntax.html. Missing features can be requested on GitHub issues.
Is JSqlParser safe to use in multi-threaded environments?
Yes, parser instances are stateless. However, review thread safety of any custom AST transformation logic you add.

Custom software development services

Adopting JSqlParser is usually one piece of a larger software development effort. As a software development agency, DEV.co provides software development services and web development expertise — pairing senior software developers and web developers with your team to design, build, and operate open-source databases software in production.

Parse SQL with Confidence

Need to analyze, validate, or transform SQL across multiple databases? JSqlParser provides a robust, actively maintained solution. Contact us to discuss how to integrate SQL parsing into your data infrastructure.