@shikijs/cli
NPM version NPM downloads GitHub
Shiki in the command line.
Usage
The Shiki CLI works like cat command, but with syntax highlighting. It also supports remote files.
npx @shikijs/cli README.mdnpx @shikijs/cli \
'https://github.com/shikijs/shiki/blob/main/taze.config.ts?raw=true'Install
You can also install it globally. Command aliases @shikijs/cli, shiki, skat are registered.
npm i -g @shikijs/cliyarn global add @shikijs/clipnpm add -g @shikijs/clibun add -g @shikijs/clideno install -gREn skat npm:@shikijs/cliskat src/index.tsOptions
--theme
Specify the theme to use. Defaults to vitesse-dark.
npx @shikijs/cli README.md --theme=nord--lang
Language is auto-inferred from the file extension. You can override it with --lang.
npx @shikijs/cli src/index.js --lang=ts--format
Specify the output format. Defaults to ansi. Supported values: ansi, html.
npx @shikijs/cli README.md --format=htmlNode.js API
The @shikijs/cli package also provides a Node.js API.
npm i @shikijs/cliyarn add @shikijs/clipnpm add @shikijs/clibun add @shikijs/clideno add npm:@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.
import { codeToANSI } from '@shikijs/cli'
const highlighted = await codeToANSI(source, 'typescript', 'nord')
console.log(highlighted)codeToANSI takes three required parameters:
code: stringlang: BundledLanguagetheme: BundledTheme