Skip to main content

iTerm2 inline images

AI-Generated Content
This page was generated with the assistance of AI and may contain inaccuracies. It is intended as a placeholder for future human verification. If you spot issues ahead of its initial review, please report them on GitHub!
Experimental

iTerm2 inline images is an image display protocol that transmits base64-encoded image data using an OSC 1337 sequence. It supports automatic format detection, flexible sizing in cells, pixels, or percentages, and aspect ratio preservation.

Syntax​

OSC 1337 ; File=[params] : base64-data ST      Display inline image
Formal syntax
iterm2-image = 0x1b, "]", "1337", ";", "File=", params, ":", data, ( 0x07 | 0x1b, "\\" ) ;
params       = param, { ";", param } ;
param        = key, "=", value ;
key          = "name" | "size" | "width" | "height" | "preserveAspectRatio" | "inline" ;
value        = char, { char } ;
data         = base64-char, { base64-char } ;
base64-char  = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J"
           | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T"
           | "U" | "V" | "W" | "X" | "Y" | "Z"
           | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j"
           | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t"
           | "u" | "v" | "w" | "x" | "y" | "z"
           | "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
           | "+" | "/" | "=" ;
char         = ? any printable ASCII character except ";" and ":" ? ;

Parameters​

ParameterDescriptionDefault
nameBase64-encoded filename. Used for display purposes and to determine file type.(empty)
sizeSize of the raw (pre-base64) file data in bytes. Optional but improves performance.(auto)
widthDisplay width. Accepts N (cells), Npx (pixels), or N% (percent of terminal width). auto uses the image's native size.auto
heightDisplay height. Accepts N (cells), Npx (pixels), or N% (percent of terminal height). auto uses the image's native size.auto
preserveAspectRatio0 to stretch the image to fill the specified dimensions; 1 to maintain the aspect ratio and fit within the bounds.1
inline1 to display the image inline at the cursor position. 0 to download the file (not displayed).0

Width/height dimension formats:

FormatExampleMeaning
Nwidth=5N terminal character cells
Npxwidth=200pxN pixels
N%width=50%N percent of the terminal's width or height
autowidth=autoUse the image's native dimension

Description​

The iTerm2 inline image protocol provides a straightforward way to display images in the terminal. The entire image is sent as a single base64-encoded blob within an OSC sequence. The terminal auto-detects the image format (PNG, JPEG, GIF, BMP, TIFF, etc.) from the file data.

Inline vs. download mode​

The inline parameter controls whether the image is displayed in the terminal or treated as a file download:

  • inline=1: The image is rendered at the current cursor position. The cursor advances past the image after display.
  • inline=0 (default): The file is saved/downloaded but not displayed. This mode is intended for file transfer, not image display. Most use cases want inline=1.

Sizing behavior​

When both width and height are set to auto (the default), the image is displayed at its native pixel size, occupying however many terminal cells that requires. When explicit dimensions are given, the terminal scales the image to fit.

If preserveAspectRatio=1 (the default), the image is scaled to fit within the bounding box defined by width and height while maintaining its proportions. If preserveAspectRatio=0, the image is stretched to exactly fill the specified dimensions.

Filename​

The name parameter is base64-encoded. It is primarily used for the download mode (inline=0) to suggest a filename, but terminals may also use it for tooltip display or format detection.

note

The entire image payload must be sent as a single OSC sequence. Unlike the Kitty graphics protocol, there is no chunked transfer mechanism. Very large images may exceed the terminal's maximum OSC string length, causing the sequence to be discarded.

Examples​

# Display a PNG image inline, auto-sized
printf '\e]1337;File=inline=1:'
base64 < image.png | tr -d '\n'
printf '\a'

# Display an image at 80 columns wide, preserving aspect ratio
printf '\e]1337;File=inline=1;width=80:'
base64 < photo.jpg | tr -d '\n'
printf '\a'

# Display at 50% of terminal width
printf '\e]1337;File=inline=1;width=50%%:'
base64 < diagram.png | tr -d '\n'
printf '\a'

# Display at exactly 200x100 pixels, stretched
printf '\e]1337;File=inline=1;width=200px;height=100px;preserveAspectRatio=0:'
base64 < icon.png | tr -d '\n'
printf '\a'

# One-liner with printf (small image)
printf '\e]1337;File=inline=1;width=10;height=5:%s\a' "$(base64 < small.png | tr -d '\n')"

# Include a filename
printf '\e]1337;File=name=%s;inline=1:%s\a' \
"$(echo -n 'photo.jpg' | base64)" \
"$(base64 < photo.jpg | tr -d '\n')"

Specifications​

SpecificationSection
iTerm2 Image Protocol—

Terminal support​

TerminalSupportVersionNotes
Terminal Emulators
Alacritty✗NoNot implemented
Bobcat✓0.9.0Explicitly documented alongside Sixel and Jexer
contour✗NoNo OSC 1337 handling found in codebase
foot✗NoNo OSC 1337 image support found
Ghostty✗NoOSC 1337 File= command is parsed but marked as unimplemented
iTerm2✓v20260216-nightlyOSC 1337;File= protocol
Kitty✗NoOSC 1337 is handled for notifications, not iTerm2 images
Konsole✓YesOSC 1337 File protocol implemented
mintty✓YesOSC 1337 File protocol implemented
mlterm✓rel-3_3_4OSC 1337 File= supported
PuTTY✗NoOSC 1337 not handled; only OSC 0, 1, 2, 4, 21 are processed
Rio✓v0.1.13
rxvt-unicode✗NoNo OSC 1337 handler found
st✗NoOSC 1337 not handled. APC sequences recognized but not processed
terminology✗No
VT100✗No
VTE✗NoOSC 1337 is parsed but not implemented - falls through to default case with no action
WezTerm✓20191124-233250-cb9fd7d
Windows Terminal✗NoOSC 1337 implemented only for SetMark action, not File= inline images
xterm✗NoNot implemented - APC sequences ignored
xterm.js✓0.4.0Requires @xterm/addon-image addon. Added in addon version 0.4.0.
Multiplexers
cy✗No
GNU Screen✗NoOSC 1337 not implemented
tmux✗NoNo OSC 1337 File= support found
tuios✗NoOSC 1337 handler not implemented
Zellij✗No

See also​