Definition

ConPTY

ConPTY is the Windows pseudo-console API that lets apps host real terminal sessions with proper ANSI, resize, and signal support.

ConPTY is Microsoft's pseudo-console API, introduced in Windows 10 version 1809. It lets any application host a fully-featured terminal session — with real ANSI escape sequences, proper window resizing, and signal forwarding — without reinventing what conhost.exe already does. Before ConPTY, Windows terminals had to scrape the legacy console buffer, which broke colors, cursor positioning, and anything resembling a modern TUI.

Why it matters

If you build a terminal emulator, multiplexer, or developer tool on Windows, ConPTY is the only sane way to run cmd.exe, PowerShell, bash, or any CLI (including Claude Code and Codex CLI) and get output that looks right. Without it, programs that use cursor movement, 256-color palettes, or alternate screen buffers render as garbled text.

SpaceSpider uses ConPTY under the hood on Windows via Rust's portable-pty crate, so every pane in a grid layout is a real pseudo-terminal, not a subprocess with redirected stdio. This is what makes tools like vim, btop, and agentic CLIs feel identical on Windows and Linux.

How it works

ConPTY exposes three Win32 APIs: CreatePseudoConsole, ResizePseudoConsole, and ClosePseudoConsole. You create the pseudo-console with a pair of pipes for input and output, then launch the child process with the pseudo-console attached via an extended STARTUPINFOEX attribute. The child inherits the pseudo-console, so when it writes ANSI sequences to stdout they travel through the pipe to your terminal renderer.

Internally, ConPTY hosts a headless conhost.exe to translate between the legacy console API (which many Windows CLIs still use) and the modern VT stream your app consumes. This compatibility shim is why old tools like diskpart still work inside a ConPTY, even though they were written long before VT sequences existed on Windows.

Resize events are forwarded by calling ResizePseudoConsole when your UI changes; the child receives a SIGWINCH-equivalent notification. Ctrl+C and signals are forwarded through the input pipe.

  • PTY — the Unix pseudo-terminal ConPTY mirrors
  • TTY — the historical teletype device terminals emulate
  • Windows Terminal — Microsoft's modern host built on ConPTY
  • ANSI escape codes — the VT sequences ConPTY transports
  • Shell — what typically runs inside a ConPTY session

FAQ

What's the difference between ConPTY and WinPTY?

WinPTY was a third-party shim that emulated a PTY by scraping the console buffer before ConPTY existed. It's slower, loses fidelity, and is now deprecated. Every modern Windows terminal — including SpaceSpider — uses ConPTY directly. See install-windows for our Windows setup notes.

Does ConPTY work in Windows Server?

Yes, from Windows Server 2019 onward. Older Server editions need the WinPTY fallback or can't host modern terminal features at all.

Related terms