Registry / productivity / highlight.js-tsql

highlight.js-tsql

JSON →
library1.3.0jsnpmunverified

A language grammar for Transact-SQL (T-SQL) to be used with the highlight.js syntax highlighting library. Current stable version is 1.3.0, released under a maintenance cadence. It provides highlighting for T-SQL code in web pages or web apps. Unlike generic SQL grammars, this one specifically targets T-SQL keywords, built-in functions, data types, and system objects. It ships TypeScript type definitions and is designed as a third-party language module for highlight.js, requiring the parent library.

npm install highlight.js-tsql
INSTALL
IMPORT
SIG · HIGHLIGHT.JS-TSQL
H
highlight.js-tsql
productivityjavascriptv1.3.0
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.

tsql
import tsql from 'highlight.js-tsql';
import { tsql } from 'highlight.js-tsql';
The module's default export is a language definition function. Named destructuring will fail.
registerLanguage usage
hljs.registerLanguage('tsql', tsql);
hljs.registerLanguage('tsql', tsql.default);
The default export is the language function itself, not an object with a default property.
CommonJS require
const hljs = require('highlight.js'); const tsql = require('highlight.js-tsql'); hljs.registerLanguage('tsql', tsql);
const tsql = require('highlight.js-tsql').default;
In CommonJS, the module exports the function as the main export, not as .default.

Imports and registers the T-SQL language grammar, then highlights a simple query string.

import hljs from 'highlight.js'; import tsql from 'highlight.js-tsql'; import 'highlight.js-tsql/dist/ssms.min.css'; import 'highlight.js/styles/github.css'; hljs.registerLanguage('tsql', tsql); const code = `SELECT * FROM sys.tables WHERE type = 'U'`; document.body.innerHTML = `<pre><code class="language-tsql">${hljs.highlight(code, { language: 'tsql' }).value}</code></pre>`;
Debug
Known issues
gotchaThe module does not include highlight.js itself; you must install it separately.
fix
Install both: npm install highlight.js highlight.js-tsql
affects: >=0.0.0
gotchaWhen using the CDN build, the script tag automatically registers the language, so calling hljs.registerLanguage again will throw a warning or error.
fix
Either use CDN script OR import/register programmatically, not both.
affects: >=1.0.0
gotchaThe language identifier is 'tsql' (lowercase), not 't-sql' or 'TSQL'.
fix
Use exactly 'tsql' when calling hljs.registerLanguage or in class names.
affects: >=0.0.0
Errors
Common errors & fixes
Error: No language with id 'tsql' found
Forgot to register the language or used wrong identifier.
fix
Ensure you call hljs.registerLanguage('tsql', tsql); with the correct import.
TypeError: tsql is not a function
Importing named export instead of default (e.g., import { tsql } from 'highlight.js-tsql').
fix
Use default import: import tsql from 'highlight.js-tsql';
Can't resolve 'highlight.js'
highlight.js is not installed or not in node_modules.
fix
Run npm install highlight.js.
Upgrade
Version history
1.3.0latest on npm
Audit
Dependencies
highlight.jsrequiredRequired as a peer dependency; this module registers a language with highlight.js and does not work without it.
Agent activity
29 hits · last 30 days
node
26
OpenAI (training)
1
Resources
highlight.js-tsql — npm install highlight.js-tsql · libregistry