Registry / database / html-query-plan

html-query-plan

JSON →
library2.6.1jsnpmunverified

html-query-plan is a JavaScript library for rendering Microsoft SQL Server execution plans as interactive HTML diagrams. The current stable version is 2.6.1, with maintenance releases as needed. It differentiates from tools like SentryOne Plan Explorer by providing a lightweight, browser-based solution that does not require Windows or SSMS. The library includes an XSLT 1.0 stylesheet for pre-rendering and JavaScript for drawing connecting lines. It supports both estimated and actual execution plans, with icons for batch mode, parallelism, and warnings. Browser support includes Chrome, Firefox, and IE9+.

npm install html-query-plan
INSTALL
IMPORT
SIG · HTML-QUERY-PLAN
H
html-query-plan
databasejavascriptv2.6.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

showPlan
import { showPlan } from 'html-query-plan'
const QP = require('html-query-plan')
ESM-only. The library does not export a default; use named import.
drawLines
import { drawLines } from 'html-query-plan'
import drawLines from 'html-query-plan'
drawLines is a named export, not default.
ShowPlanOptions
import type { ShowPlanOptions } from 'html-query-plan'
TypeScript type available for the options object.

Renders a SQL Server execution plan XML into an HTML container with interactive diagrams and tooltips.

import { showPlan } from 'html-query-plan'; const planXml = `<?xml version="1.0"?> <ShowPlanXML xmlns="http://schemas.microsoft.com/sqlserver/2004/07/showplan"> <BatchSequence> <Batch> <Statements> <StmtSimple StatementText="SELECT * FROM [SalesLT].[Product] WHERE [ListPrice] > 1000" StatementId="1" StatementCompId="1" StatementType="SELECT" StatementSubType="" StatementEstRows="12.345" SecurityPolicyApplied="false"> <QueryPlan DegreeOfParallelism="0" CachedPlanSize="16" CompileTime="2" CompileCPU="1" CompileMemory="88"> <RelOp NodeId="0" PhysicalOp="Clustered Index Scan" LogicalOp="Clustered Index Scan" EstimateRows="12.345" EstimateIO="0.01" EstimateCPU="0.01" AvgRowSize="200" EstimatedTotalSubtreeCost="0.02" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"> <OutputList> <ColumnReference Database="[AdventureWorksLT2008]" Schema="[SalesLT]" Table="[Product]" Column="*" /> </OutputList> <RunTimeInformation> <RunTimeCountersPerThread Thread="0" ActualRows="12" ActualEndOfScans="1" ActualRebinds="0" ActualRewinds="0" /> </RunTimeInformation> <IndexScan Lookup="0"> <DefinedValues> <DefinedValue> <ColumnReference Database="[AdventureWorksLT2008]" Schema="[SalesLT]" Table="[Product]" Column="*" /> </DefinedValue> </DefinedValues> <Object Database="[AdventureWorksLT2008]" Schema="[SalesLT]" Table="[Product]" Index="[PK_Product_ProductID]" Alias="[Product]" IndexKind="Clustered" Storage="RowStore" /> </IndexScan> </RelOp> </QueryPlan> </StmtSimple> </Statements> </Batch> </BatchSequence> </ShowPlanXML>`; const container = document.getElementById('planContainer'); if (container) { showPlan(container, planXml); } else { console.error('Container element not found'); }
Debug
Known issues
deprecatedThe global `QP` object is deprecated. Use module imports instead.
fix
Switch to `import { showPlan } from 'html-query-plan'`.
affects: >=2.0.0
gotchaThe XSLT pre-rendering requires the qp.xslt file to be available separately. The library does not include it in the default bundle.
fix
Download qp.xslt from the GitHub releases and apply it server-side before calling drawLines.
affects: >=1.0.0
gotchaIE8 and earlier are not supported. The library uses CSS features and JavaScript that are not available in older browsers.
fix
Use a modern browser like Chrome, Firefox, or IE9+.
affects: >=1.0.0
breakingIn version 2.0.0, the library switched from a single global `QP` to module-based exports. Existing code using global `QP.showPlan` will break.
fix
Update to use ES module imports: `import { showPlan } from 'html-query-plan'`.
affects: >=2.0.0 <2.0.0
Errors
Common errors & fixes
Uncaught ReferenceError: QP is not defined
Using the legacy global `QP` object without importing the library as a module.
fix
Use `import { showPlan } from 'html-query-plan'` instead of relying on the global `QP`.
Cannot find module 'html-query-plan' or its corresponding type declarations.
Missing or incorrect TypeScript configuration or the library is not installed.
fix
Run `npm install html-query-plan` and ensure tsconfig.json includes `"moduleResolution": "node"`.
Failed to parse XML: The document is not well-formed.
The execution plan XML provided is invalid or incomplete.
fix
Ensure the XML is a valid ShowPlanXML string with proper encoding and no byte order marks.
Upgrade
Version history
2.6.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
html-query-plan — npm install html-query-plan · libregistry