Raw capture โ raw/sql-crack.md
url: https://github.com/buva7687/sql-crack date_fetched: 2026-07-05 backfilled: true
Transform SQL queries into interactive visual flow diagrams
Features โข Dialects โข Installation โข Usage โข Configuration โข Contributing
SQL Crack is a VS Code extension that visualizes SQL queries as interactive execution flow diagrams. Understand complex queries at a glance, track data lineage across your entire workspace, and identify optimization opportunities with professional-grade visual analysis.
Inspired by JSON Crack and Snowflake Query Profile
| Feature | Description |
|---|---|
| Execution Flow | See how your SQL executes step-by-step with color-coded operation nodes |
| Multi-Query Support | Visualize multiple statements with tab navigation (Q1, Q2, Q3...) |
| Column Lineage | Click any output column to trace its transformation path through JOINs, aggregations, and calculations |
| Legend Bar (Default On) | Bottom legend is visible on first open, dismissable, and remembers your preference |
| Command Palette | Press Cmd/Ctrl + Shift + Pinside the webview for quick action search |
| CTE & Subquery Expansion | Double-click to expand CTEs/subqueries in floating cloud panels with independent pan/zoom |
| Undo / Redo Layout History | Revert or re-apply drag, zoom, layout, and focus-mode changes with toolbar controls or keyboard shortcuts |
| Query Compare Mode | Compare baseline vs current query side-by-side with added/removed/changed node highlights and stats deltas |
| Query Statistics | Complexity score, CTE depth, fan-out analysis, and performance score (0-100) |
Large graph behavior: For SQL Flow graphs with100+nodes, SQL Crack automatically enables clustering to keep rendering responsive. Search and keyboard navigation follow the currently rendered graph, so collapsed clusters behave differently from a fully expanded graph.
Node Types: Table (Blue) โข Filter (Purple) โข Join (Pink) โข Aggregate (Amber) โข Window (Fuchsia) โข Sort (Green) โข Limit (Cyan) โข Select (Indigo) โข Union/Set Op (Slate) โข CTE (Purple) โข Subquery (Violet) โข Case (Orange) โข Result (Green)
Operation Badges: READ (Blue) โข WRITE (Red) โข DERIVED (Teal) โข CTE (Purple) โข SQ (Violet) โข INSERT (Green) โข UPDATE (Amber) โข DELETE (Dark Red) โข MERGE (Violet) โข CTAS (Cyan)
Analyze cross-file dependencies across your entire SQL project with three main views:
Dependency graph showing file and table relationships with color-coded edges for SELECT, JOIN, INSERT, UPDATE, and DELETE operations. Includes a selection panel with upstream/downstream context, focus mode, and an index freshness badge, plus guided empty-state prompts when the graph is empty or search yields no matches.
Explore data lineage across tables, views, and CTEs with:
U), downstream only (- D), or all connections (- A)Analyze change impact (MODIFY/RENAME/DROP) with severity indicators, grouped transitive impacts, and source โ target column paths.
Common Features (all views):
| Analysis | Description |
|---|---|
| Quality Warnings | Unused CTEs, dead columns, duplicate subqueries, repeated table scans |
| Performance Hints | Filter pushdown, join order, index suggestions, non-sargable expressions |
| Performance Score | 0-100 score based on detected anti-patterns |
| Inline Diagnostics | SQL Crack hints surface as VS Code diagnostics with a quick fix to open SQL Flow |
| Capability | Description |
|---|---|
| Partial Parse Fallback | If AST parsing fails, SQL Crack falls back to regex extraction to still render best-effort tables/joins |
| Auto-Retry Dialect | Detects dialect-specific syntax patterns and retries parsing with the correct dialect when the selected one fails |
| Nested CTE Hoisting | Automatically rewrites Snowflake/Tableau-style FROM (WITH ... SELECT ...)subqueries to top-level CTEs for full visualization |
| PostgreSQL Syntax Preprocessing | Automatically rewrites AT TIME ZONE,timestamptz '...', and other type-prefixed literals for full AST parsing, including during dialect auto-retry |
| Safer Dialect Detection | Reduces false positives in dialect pattern matching (for example time literals like 00:00:00) so valid queries are less likely to fall back unnecessarily |
| Large File Handling | Parses within configurable file/statement limits and clearly reports truncation instead of failing hard |
| Web Worker Parsing | SQL parsing runs off the main thread via a dedicated Web Worker, keeping the UI responsive during large queries. Falls back to synchronous parsing when workers are unavailable. |
| Timeout Protection | Configurable parse timeout prevents UI hangs on pathological queries |
| MERGE / UPSERT Coverage | Supports MERGE-style visualization and dialect-native upsert patterns ( ON CONFLICT,ON DUPLICATE KEY) |
| TVF Awareness | Recognizes common table-valued functions across PostgreSQL, Snowflake, BigQuery, and SQL Server |
| DBT/Jinja Preprocessing | Automatically rewrites {{ ref() }},{{ source() }},{% if/else %}, and other Jinja templates to valid SQL so DBT projects visualize correctly |
| Actionable Parse Errors | Parse diagnostics include source line context in the badge and canvas overlay, not just line/column numbers |
Performance Icons: Filter Pushdown (โฌ) โข Non-Sargable (๐ซ) โข Join Order (โ) โข Index Suggestion (๐) โข Repeated Scan (๐) โข Complex (๐งฎ)
Note: This is heuristic-based static analysis. For production optimization, validate with actual query plans (EXPLAIN ANALYZE).
Cmd/Ctrl + FHover Tooltipsโ Detailed information on hover for nodes and edges
Layout Pickerโ Toolbar picker with SVG icons for vertical, horizontal, compact, force, and radial layouts
Hor jump directly with keys- 1-- 5Ffor distraction-free viewingMySQL โข PostgreSQL โข SQL Server โข MariaDB โข SQLite โข Snowflake โข BigQuery โข Redshift โข Hive โข Athena โข Trino โข Oracle โข Teradata
Cmd+Shift+X/Ctrl+Shift+X)Or install directly: SQL Crack on Marketplace
Cmd+Shift+X/Ctrl+Shift+X)Or install from Open VSX Registry.
git clone https://github.com/buva7687/sql-crack.git
cd sql-crack
npm install
npm run package
Install the generated .vsix file via Extensions โ โขโขโข โ Install from VSIX.
.sqlfileCmd+Shift+L(Mac) /Ctrl+Shift+L(Windows/Linux)Right-click โ "SQL Crack: Visualize SQL Query"
Click the
Cursor note: Some Cursor builds do not render custom editor-title icons consistently. If the title icon is not visible, run
SQL Crack: Visualize SQL Queryfrom the Command Palette (Cmd/Ctrl+Shift+P) or use the context menu.
Analyze cross-file dependencies:
Tip:Re-open the panel anytime by running the same command from the Command Palette.
| Shortcut | Action |
|---|---|
Cmd/Ctrl + Shift + L |
Open visualization |
Cmd/Ctrl + Shift + P |
Open command palette |
Cmd/Ctrl + For/ |
Search nodes |
Enter/โ |
Next search result |
โ |
Previous search result |
Escape |
Clear selection |
C |
Toggle column lineage |
L |
Toggle legend |
S |
Toggle SQL preview |
Q |
Toggle query stats |
O |
Toggle hints/optimization panel |
H |
Cycle layout (vertical โ horizontal โ compact โ force โ radial) |
1-5 |
Jump directly to a specific layout option |
E |
Expand/collapse all CTEs |
U/D/A |
Focus mode: upstream / downstream / all |
T |
Toggle theme |
F |
Toggle fullscreen |
R |
Reset view (fit to screen) |
+/- |
Zoom in / out |
Cmd/Ctrl + Z |
Undo latest layout change |
Cmd/Ctrl + Shift + Z |
Redo layout change |
[/] |
Previous/next query |
? |
Show all shortcuts |
| Shortcut | Action |
|---|---|
Cmd/Ctrl + F |
Focus graph search |
Escape |
Clear search or selection |
F |
Toggle focus mode (neighbors only) |
R |
Reset view (fit to screen) |
| Shortcut | Action |
|---|---|
U |
Focus upstream only |
D |
Focus downstream only |
A |
Show all connections |
C |
Toggle column lineage |
Scroll |
Zoom in/out |
Drag |
Pan the view |
All toolbar buttons have ARIA labels for screen readers. Graph nodes are keyboard-navigable:
| Key | Action |
|---|---|
Tab |
Focus next node |
Enter/Space |
Select focused node |
Arrow keys |
Navigate between nodes |
Escape |
Deselect and return to canvas |
UI transitions and entrance animations also respect prefers-reduced-motion.
| Setting | Default | Description |
|---|---|---|
sqlCrack.defaultDialect |
MySQL |
SQL dialect for parsing |
sqlCrack.autoDetectDialect |
true |
Auto-detect dialect from query content. Disable for single-dialect repos where auto-detection produces false positives. |
sqlCrack.viewLocation |
tab |
Panel location: beside,tab |
sqlCrack.defaultLayout |
vertical |
Initial SQL Flow graph layout: vertical,horizontal,compact,force,radial. Layout only; it does not change SQL execution semantics or lineage direction. |
sqlCrack.autoRefresh |
true |
Auto-refresh on SQL changes |
sqlCrack.autoRefreshDelay |
500 |
Debounce delay in ms (100-5000) |
sqlCrack.gridStyle |
lines |
Visual canvas background style: dots,lines,none |
sqlCrack.nodeAccentPosition |
left |
Visual-only node accent strip position: left,bottom |
sqlCrack.showMinimap |
auto |
Minimap visibility: auto,always,never.autoshows it only for multi-node graphs. |
sqlCrack.colorblindMode |
off |
Color accessibility mode: off,deuteranopia,protanopia,tritanopia |
| Setting | Default | Description |
|---|---|---|
sqlCrack.workspaceAutoIndexThreshold |
50 |
Max files to auto-index (10-500) |
sqlCrack.workspaceLineageDepth |
5 |
Default lineage traversal depth (1-20) |
sqlCrack.workspaceGraphDefaultMode |
tables |
Default Graph tab mode: files,tables |
| Setting | Default | Description |
|---|---|---|
sqlCrack.additionalFileExtensions |
[] |
Additional file extensions to treat as SQL (e.g. .hql,.bteq,.tpt,.dbsql,.sql.j2). With or without the leading dot is accepted and normalized. Compound extensions likesql.j2are preserved. |
Files with these extensions will show the SQL Crack icon in the editor title bar and can be visualized like .sql files. They are also included in workspace analysis (find files, index), trigger incremental index updates on save/create/delete, and watcher patterns are refreshed when the extension setting changes. Workspace indexing intentionally skips dependency/build folders (node_modules, .git, dist, build).
| Setting | Default | Description |
|---|---|---|
sqlCrack.customAggregateFunctions |
[] |
Custom aggregate function names (e.g., ["MY_SUM"]) |
sqlCrack.customWindowFunctions |
[] |
Custom window function names (e.g., ["MY_RANK"]) |
| Setting | Default | Description |
|---|---|---|
sqlCrack.advanced.defaultTheme |
light |
Theme: auto,dark,light |
sqlCrack.advanced.showDiagnosticsInProblems |
false |
Show SQL Crack hints/errors in VS Code Problems panel |
sqlCrack.advanced.showDeadColumnHints |
true |
Show warnings for unused columns |
sqlCrack.advanced.combineDdlStatements |
false |
Merge consecutive DDL into single tab |
sqlCrack.advanced.maxFileSizeKB |
100 |
Max SQL file size before truncation handling (10-10000) |
sqlCrack.advanced.maxStatements |
50 |
Max statements parsed per file (1-500) |
sqlCrack.advanced.deferredQueryThreshold |
50 |
Query count threshold before SQL Flow compacts non-active query graphs and hydrates them on demand (1-500) |
sqlCrack.advanced.parseTimeoutSeconds |
5 |
Parser timeout in seconds (1-60) |
sqlCrack.advanced.debugLogging |
false |
Enable verbose SQL Crack output-channel logs |
sqlCrack.advanced.workspaceUxInstrumentation |
false |
Enable local-only Workspace Graph UX metrics in the SQL Crack output channel; no external telemetry is sent |
sqlCrack.advanced.cacheTTLHours |
24 |
Workspace index cache duration in hours. 0skips cached restore and forces a rebuild when opening Workspace Dependencies (max 168) |
| Problem | Solution |
|---|---|
| Icon not showing for custom extensions | In Settings โ SQL CrackโAdditional File Extensions, add one item per extension (e.g. .hql, .tpt). With or without a leading dot is fine; the extension normalizes automatically. Reload the window if the icon still doesnโt appear. |
| Parse error on valid SQL | Try a different dialect from the dropdown. SQL Crack auto-retries when it detects a stronger dialect match, but some vendor-specific syntax may still require manually switching (PostgreSQL is usually the most permissive fallback). |
| Graph is slow with large files | SQL files over 100KB or 50+ statements may be slow. Try visualizing smaller sections by selecting text first. |
| CTE/Subquery not expanding | Double-click the node. If it has no children, it may be a simple reference. |
| Workspace indexing stuck | Click Cancel in the notification, then try again. For very large workspaces, increase workspaceAutoIndexThreshold. |
| Columns not highlighting | Press Cto enable column lineage mode first, then click output columns in the SELECT node. |
To see detailed logs:
sqlCrack.advanced.debugLoggingin VS Code settingsFor lower-level diagnostics you can also open Help โ Toggle Developer Tools โ Console and filter by "SQL Crack".
If the extension behaves unexpectedly:
For workspace index issues, re-run "SQL Crack: Analyze Workspace Dependencies"to rebuild the index, or setCache TTLto0(Advanced) and reload the window
100% Localโ All processing happens in VS Code
npm install # Install dependencies
npm run compile # Build extension
npm run watch # Watch mode
npm run typecheck # Type check
npm run lint # Lint code
Press F5 to launch the Extension Development Host.
src/
โโโ extension.ts # Extension entrypoint, commands, lifecycle
โโโ visualizationPanel.ts # SQL Flow webview panel orchestration
โโโ dialects/ # Dialect registry/config
โโโ shared/ # Cross-layer tokens/utils/messages
โ โโโ messages/ # Typed host/webview message contracts
โโโ webview/ # Browser-side SQL Flow runtime
โ โโโ index.ts # Webview bootstrap + wiring
โ โโโ sqlParser.ts # Parse orchestrator
โ โโโ renderer.ts # Render orchestrator
โ โโโ parser/ # Extracted parser modules (validation, dialects, hints, statements, extractors)
โ โโโ rendering/ # Node/edge/cloud/viewport rendering modules
โ โโโ features/ # Export, lineage, theme, minimap, focus, search, metadata
โ โโโ interaction/ # Event listeners, drag/zoom/keyboard, pulse/selection
โ โโโ navigation/ # Node/table/keyboard navigation helpers
โ โโโ panels/ # Info/stats/sql panel renderers
โ โโโ state/ # Renderer state factories
โ โโโ constants/ # Color/theme constants
โ โโโ types/ # Webview runtime types
โ โโโ ui/ # Toolbar/context menu/tooltip/layout/command UI
โ โ โโโ toolbar/ # Extracted toolbar component modules
โ โโโ parser.worker.ts # Off-main-thread SQL parse worker
โโโ workspace/ # Extension-host workspace analysis runtime
โโโ workspacePanel.ts # Workspace panel orchestrator
โโโ scanner.ts # SQL file discovery/scanning
โโโ indexManager.ts # Incremental index/cache/watcher
โโโ handlers/ # Message routing + command handlers
โโโ panel/ # Workspace panel/page/export/stats modules
โโโ lineage/ # Cross-file lineage graph + analyzers
โโโ extraction/ # Definition/reference extraction pipeline
โโโ graph/ # Workspace graph build/filter/layout modules
โโโ ui/ # Workspace webview scripts/styles/views
Data Flow:
.sqlfile โextension.tscreatesVisualizationPanelsqlParser.ts(node-sql-parser) โ AST โFlowNode[]+FlowEdge[]renderer.tsโ SVG with dagre layoutUser interactions โ message passing between webview and extension host
โ Phase 1โ Core visualization (execution flow, CTE expansion, fullscreen)
0.9.0: Security & reliability hardening โ production dependency upgrades (npm audit --omit=dev reports 0 advisories), cryptographically strong CSP nonces and collision-free pin/tab IDs, stricter HTML-attribute / DOT / Mermaid export escaping, source-scoped auto-refresh and cursor-follow, a workspace index cache keyed by scope/dialect/config, and a non-blocking parser-worker timeout.
0.7.0 shipped on 2026-03-23: Web Worker parsing (off-main-thread for large files) and architecture debt remediation (pure computation extraction, fake DOM testing, integration test coverage) are now part of the released baseline.
Contributions are welcome!
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)Found a bug or have a feature request? Open an issue with:
MIT License โ see LICENSE for details.
Made with SQL for the SQL community