@shikijs/cli
Shiki in the command line.
Usage
The Shiki CLI works like cat command, but with syntax highlighting.
bash
npx @shikijs/cli README.mdInstall
You can also install it globally. Command aliases @shikijs/cli, shiki, skat are registered.
sh
npm i -g @shikijs/clish
yarn global add @shikijs/clish
pnpm add -g @shikijs/clish
bun add -g @shikijs/clish
skat src/index.tsOptions
--theme
Specify the theme to use. Defaults to vitesse-dark.
bash
npx @shikijs/cli README.md --theme=nord--lang
Language is auto-inferred from the file extension. You can override it with --lang.
bash
npx @shikijs/cli src/index.js --lang=tsNode.js API
The @shikijs/cli package also provides a Node.js API.
sh
npm i @shikijs/clish
yarn add @shikijs/clish
pnpm add @shikijs/clish
bun add @shikijs/clicodeToANSI
The asynchronous codeToANSI function allows you to convert code to ANSI escape codes for terminal output. This is useful for rendering syntax-highlighted code in the terminal.
ts
import { codeToANSI } from '@shikijs/cli'
const highlighted = await codeToANSI(source, 'typescript', 'nord')
console.log(highlighted)codeToANSI takes three required parameters:
code: stringlang: BundledLanguagetheme: BundledTheme