libghostty-vt is a portable, high-performance C library for terminal emulation. It is open source and MIT licensed.
- It is highly generic: you give it the bytes a program writes, and it processes and exposes the state of the terminal such as the screen, the cursor, the scrollback, etc.
- It is highly portable: we build and test libghostty-vt for Linux, macOS, iOS, Android, FreeBSD, Windows, WebAssembly, and bare-metal RISC-V and ARM. It works on 32-bit and 64-bit systems.
- It is high-performance: the IO throughput is best-in-class and faster than any other known terminal emulator. Memory usage is highly optimized, one libghostty-vt consumer was able to run 10,000 active (input/output) terminals with a running shell on a 4 core 8 GB Linux machine.
- It has no dependencies: For the highest performance, the library only needs libc, but you can optionally build it without that requirement and it can be fully freestanding on its own and run directly on hardware.
You can use libghostty-vt to build:
- Terminal emulators and multiplexers
- Web terminals and remote sessions
- Session recording and playback
- Test harnesses for TUI apps
- Agents and automation that read what a TUI is showing
- Etc.
libghostty-vt was originally extracted from Ghostty, but since then is in use by hundreds of projects both free and commercial. We don't have any tracking of course but by our best estimates libghostty-vt is used by tens of millions of people daily across every major desktop and mobile platform.
- Important
- libghostty-vt is pre-1.0. The core code is extremely stable and already in use by millions worldwide, but we're still stabilizing the ABI. We will ship a stable ABI with 1.0 soon. See Stability for exactly what can break.
Where to Next?
Example
Here is a complete program. It creates a terminal, writes some text with a color sequence in it, and prints what ended up on the screen. We left out the error checks to keep it short.
#include <stdio.h>
#include <string.h>
int main(void) {
const char *text = "Hello, \x1b[1;32mworld\x1b[0m!\r\n";
uint8_t *buf = NULL;
size_t len = 0;
fwrite(buf, 1, len, stdout);
putchar('\n');
return 0;
}
Full program: c-vt-hello/src/main.c
It prints Hello, world! in plain text. The color is in the terminal's state but the way we configured the formatter doesn't show it. This has no GUI window and doesn't use a real PTY, but it is hopefully demonstrative of libghostty-vt and how you could hook it up to both.