supports-terminal-graphics
Detect which terminal graphics protocols are supported (Kitty, iTerm2, Sixel)
Detects support for terminal graphics protocols using environment variables. This allows apps to choose the best available protocol for displaying images in the terminal.
Protocols
| Kitty | Best | Truecolor RGBA, transparency, animation support |
| iTerm2 | Good | Full color, native macOS rendering |
| Sixel | Basic | Palette-based, widely supported legacy protocol |
Install
npm install supports-terminal-graphics
Usage
import supportsTerminalGraphics from 'supports-terminal-graphics';
if (supportsTerminalGraphics.stdout.kitty) {
} else if (supportsTerminalGraphics.stdout.iterm2) {
} else if (supportsTerminalGraphics.stdout.sixel) {
} else {
}
You can also check stderr:
if (supportsTerminalGraphics.stderr.kitty) {
}
API
supportsTerminalGraphics
Returns an object with stdout and stderr properties, each containing:
kitty - boolean - Whether Kitty graphics protocol is supported
iterm2 - boolean - Whether iTerm2 inline images protocol is supported
sixel - boolean - Whether Sixel protocol is supported
createSupportsTerminalGraphics(stream?)
Create a custom check for a specific stream.
import {createSupportsTerminalGraphics} from 'supports-terminal-graphics';
const support = createSupportsTerminalGraphics(process.stdout);
console.log(support.kitty);
console.log(support.iterm2);
console.log(support.sixel);
Terminal Support
| Kitty | ✓ | | |
| Ghostty | ✓ | | |
| WezTerm | ✓ | ✓ | ✓ |
| iTerm2 (v3.6+) | ✓ | ✓ | |
| iTerm2 (v2.9.20150512+) | | ✓ | |
| Konsole (22.04+) | ✓ | ✓ | ✓ |
| VS Code (v1.80+) | | ✓ | ✓ |
| Rio | ✓ | ✓ | ✓ |
| Warp | ✓ | | |
| mintty | | ✓ | ✓ |
| mlterm | | | ✓ |
Related