Skip to main content
ansicode

Kitty graphics protocol — Inline pixel images (ESC _ G … ESC \)

Modern alternative to Sixel: stream PNG / RGBA bytes to the terminal via the Kitty APC frame, with sane chunking and a placement protocol.

Byte forms

Every common string-literal form so you can paste-and-search either direction.

\\x1b[\x1b_Ga=T,f=100,m=1;BASE64_CHUNK\x1b\\
\\033[\033_Ga=...;PAYLOAD\033\\
\\e[\e_G a=...;PAYLOAD \e\\
ESC [ESC _ G key=value,... ; BASE64 ESC \
hex1b 5f 47 ... 1b 5c

Description

The Kitty graphics protocol — designed by kitty.sh as a saner alternative to Sixel/iTerm-img — uses the APC (Application Program Command) frame: introducer `\x1b_` (ESC _ ), the literal `G` to mark a graphics command, a comma-separated key=value control header (`a=T` transmit + display, `f=100` PNG, `f=24` RGB, `f=32` RGBA, `s` `v` width/height in pixels, `m=1` more chunks coming / `m=0` last chunk, `i=ID` image ID for re-placement), `;`, then a base64 payload of up to 4096 bytes per chunk, terminated by ST (`\x1b\\`). Supported natively by kitty + ghostty + wezterm; konsole has partial support. iTerm2's own `\x1b]1337;File=...` proprietary protocol is an alternative; both are converging on Kitty's design. Sixel (DCS `Pq`) is the legacy fallback for terminals without either.

Spec citation: Kitty Graphics Protocol (sw.kovidgoyal.net/kitty/graphics-protocol/)

Examples

bash
# Display a PNG file inline (one-shot, no chunking):\nb64=$(base64 -w0 cat.png)\nprintf '\033_Ga=T,f=100;%s\033\\' "$b64"
python
import base64, sys\npng = open('cat.png','rb').read()\nsys.stdout.write('\x1b_Ga=T,f=100;' + base64.b64encode(png).decode() + '\x1b\\')
go
data, _ := os.ReadFile("cat.png")\nfmt.Printf("\x1b_Ga=T,f=100;%s\x1b\\\\", base64.StdEncoding.EncodeToString(data))
javascript
import fs from 'node:fs';\nconst b64 = fs.readFileSync('cat.png').toString('base64');\nprocess.stdout.write('\x1b_Ga=T,f=100;' + b64 + '\x1b\\')
c
/* read PNG into buf, base64-encode, then: */\nprintf("\x1b_Ga=T,f=100;%s\x1b\\\\", b64);

Terminal support

xterm
no
Linux console (fbcon)
no
macOS Terminal.app
no
iTerm2
partial
Windows Terminal
no
cmd.exe / ConPTY
no
kitty
yes
alacritty
no
WezTerm
yes
Ghostty
yes
GNOME Terminal
no
Konsole
partial
tmux
no
GNU screen
no

Related sequences

In the family cookbook

DCS cookbook · 2. Pictures inside the stream — Sixel and Kitty graphics