node-pty lets Node programs fork child processes attached to pseudoterminal file descriptors for interactive terminal I/O. It supports Linux, macOS, and Windows via the ConPTY API.
Overview
node-pty exposes native pseudoterminal bindings to JavaScript so applications can spawn shells or CLI tools that expect a TTY. The returned terminal object supports asynchronous reads and writes, which is how many terminal emulators and IDEs embed real shells.
On Linux and macOS the implementation follows forkpty-style behavior, while Windows builds target the ConPTY API on supported Windows releases rather than the older winpty path. Optional automatic flow control can interpret pause and resume control characters to avoid overwhelming consumers.
The library is widely used by terminal applications and documents security considerations because child processes inherit the parent permission level. It is not thread-safe across Node worker threads. Building from source requires platform-specific toolchains such as Xcode on macOS or Visual Studio components on Windows.
Key features
- Fork processes with pseudoterminal descriptors
- Read and write via terminal objects
- Linux and macOS forkpty bindings
- Windows ConPTY support
- Optional XON/XOFF flow control
- Customizable flow control messages
- TypeScript API declarations
- Used by multiple terminal emulators
Use cases
- Embedding shells in terminal emulator apps
- Running TUI programs that need a real TTY
- Sending control sequences from Node hosts
- Building web-based terminals atop Node servers
- Automating interactive CLI tools