Skip to main content
v1.13.0 - ClickHouse Dialect

Parse SQL at the speed of Go

Production-ready SQL parsing with zero-copy tokenization, object pooling, and multi-dialect support

query.sql
SELECT
  u.name,
  u.email,
  COUNT(o.id) AS order_count,
  SUM(o.total) AS lifetime_value
FROM users u
LEFT JOIN orders o ON o.user_id = u.id
WHERE u.created_at > '2024-01-01'
GROUP BY u.name, u.email
HAVING COUNT(o.id) > 5
ORDER BY lifetime_value DESC
LIMIT 20;
AST Outputparsed in <1ms
{
  "type": "Query",
  "body": {
    "type": "Select",
    "projection": [
      { "type": "CompoundIdentifier", "value": "u.name" },
      { "type": "CompoundIdentifier", "value": "u.email" },
      { "type": "Function", "name": "COUNT",
        "args": ["o.id"], "alias": "order_count" },
      { "type": "Function", "name": "SUM",
        "args": ["o.total"], "alias": "lifetime_value" }
    ],
    "from": {
      "type": "Join", "join_type": "LEFT",
      "left": { "type": "Table", "name": "users", "alias": "u" },
      "right": { "type": "Table", "name": "orders", "alias": "o" }
    },
    "selection": { "type": "BinaryOp", "op": ">" },
    "group_by": ["u.name", "u.email"],
    "having": { "type": "BinaryOp", "op": ">" },
    "order_by": [{ "expr": "lifetime_value", "asc": false }],
    "limit": 20
  }
}
Try Interactive Playground
1,380,000+

ops/sec

<1μs

latency

85%

SQL-99

7

Dialects

Built for Production

Multi-Dialect

PostgreSQL, MySQL, SQLite, SQL Server, Oracle, Snowflake, ClickHouse.

Thread-Safe

Zero race conditions. 20,000+ concurrent ops tested.

Zero-Copy

Direct byte slice operations. No unnecessary allocations.

Object Pooling

sync.Pool recycling for ASTs, tokenizers, expressions.

Security Scanner

SQL injection detection with severity classification.

MCP Server

7 SQL tools for Claude, Cursor, and any MCP client.

Simple, Powerful API

main.go
1package main
2 
3import "github.com/gosqlx/gosqlx/pkg/gosqlx"
4 
5func main() {
6 // Parse SQL into an AST
7 ast, err := gosqlx.Parse("SELECT * FROM users WHERE active = true")
8 if err != nil {
9 log.Fatal(err)
10 }
11 fmt.Println(ast.Statements)
12}

AI-Ready SQL Tools

Connect 7 SQL tools to Claude, Cursor, or any MCP client — no installation, no API key.

Terminal
$ claude mcp add --transport http gosqlx https://mcp.gosqlx.dev/mcp
✓ Added gosqlx (7 tools available)
parse_sqlformat_sqlvalidate_sqllint_sqlanalyze_sqldetect_injectionlist_dialects

IDE Integration

Real-time SQL validation, formatting, and linting in VS Code. Catch errors as you type with full multi-dialect support.

Install Extension
query.sql — GoSQLX
1SELECT u.id, u.name, u.email
2FROM users u
3JOIN orders o ON o.user_id = u.id
4WHERE u.active = true
5ORDER BY u.name ASC;
Valid SQL|PostgreSQL
0 issues
GitHub StarsTestsGo Report CardGoDoc

Ready to parse SQL at the speed of Go?