[GoSQLX: a gopher mascot with a magnifying glass, a database and a rising arrow]
GoSQLX
Pure-Go SQL parser, formatter, linter and security scanner for 8 dialects.
[CI]
[Go Reference]
[Release]
[License]
[OpenSSF Scorecard]
Playground · Docs · Benchmarks · VS Code · MCP server
† Parse stage only (pre-tokenized input to AST), SELECT id, name FROM users, Apple M4, Go 1.27, median of 20 runs of BenchmarkPerformanceBaseline. Complex queries take longer (see performance_baselines.json). Reproduce: go test -run ^$ -bench BenchmarkPerformanceBaseline -benchmem -count=20 ./pkg/sql/parser/.
[Terminal demo: gosqlx validate, format and lint on one query, then the WASM playground]
What is GoSQLX?
GoSQLX is a production-ready SQL parsing SDK for Go. It tokenizes, parses, and generates ASTs from SQL with zero-copy optimizations and intelligent object pooling - parsing a simple SELECT in about 363 ns (~2.8M parses/sec).
Why GoSQLX?
- Not an ORM - a parser. You get the AST, you decide what to do with it.
- Not slow - zero-copy tokenization, sync.Pool recycling, no allocations on hot paths.
- Not limited - PostgreSQL, MySQL, MariaDB, SQL Server, Oracle, SQLite, Snowflake, ClickHouse. CTEs, window functions, MERGE, set operations.
- Not just a library - CLI, VS Code extension, GitHub Action, MCP server, WASM playground, Python bindings.
Install
Go library
CLI
VS Code
The extension bundles the binary, so there is no extra setup. Learn more.
MCP server
7 SQL tools in Claude, Cursor, or any MCP client. MCP guide.
Claude Code plugin (skills, slash commands, SQL reviewer agent): /plugin marketplace add ajitpratap0/GoSQLX then /plugin install gosqlx@gosqlx - details.
ChatGPT app: add https://mcp.gosqlx.dev/mcp as a connector in developer mode for an interactive analysis widget - details.
[MCP]
[Glama MCP Server]
GitHub Action
Quick start
Source: examples/readme_quickstart/main.go, compiled in CI against HEAD and the latest release.
Output:
Formatting turns one-line SQL into a readable query:
[Before: one-line lowercase SQL. After gosqlx format: SELECT, FROM, INNER JOIN, WHERE, GROUP BY, HAVING, ORDER BY and LIMIT each on their own line]
Features
[Architecture: SQL bytes go through the tokenizer to TokenWithSpan, the parser builds an AST, and the formatter, linter, security scanner, transpiler and fingerprinter consume it]
- Parser - zero-copy tokenizer, recursive descent parser and full AST generation.
- Analysis - SQL injection scanner, 30 lint rules (L001-L030), 20 optimizer rules and metadata extraction.
- Tooling - AST-based formatter, query transforms API, VS Code extension and GitHub Action.
- Syntax highlighting - dialect-aware highlighting for terminals (ANSI), HTML/CSS, JSON spans, LSP semantic tokens and WASM;
gosqlx highlight query.sql or gosqlx.HighlightANSI(sql).
- Multi-dialect - 8 dialects with dedicated grammar support: PostgreSQL, MySQL, MariaDB, SQL Server, Oracle, SQLite, Snowflake, ClickHouse. The
--dialect flag and WithDialect accept 11 names: those 8 (postgresql, mysql, mariadb, sqlserver, oracle, sqlite, snowflake, clickhouse) plus generic, bigquery and redshift. BigQuery and Redshift have no dialect-specific keyword set (they use the generic keywords) and only capability-gated grammar, such as BigQuery's QUALIFY, PIVOT/UNPIVOT, UNNEST in FROM and (struct).field access.
- AI-ready - MCP server with 7 tools, public remote endpoint, Streamable HTTP.
- Tested - race-detector clean in CI, ~80-85% SQL-99 (estimated).
Documentation
Contributing
GoSQLX is built by contributors like you. Whether it's a bug fix, new feature, documentation improvement, or just a typo - every contribution matters.
- Fork & branch from
main
- Write tests - we use TDD and require race-free code
- Run
task check - must pass before PR
- Open a PR - we review within 24 hours
Contributing Guide · Code of Conduct · Governance
Community
Questions or ideas: Discussions. Found a bug or want a feature: Issues.
License
Apache License 2.0 - see LICENSE for details.