Node.js tty: terminal streams and raw mode
Answer: tty.ReadStream is the readable side of a TTY. isTTY is always true for those instances. setRawMode makes the stream operate as a raw device.
Examples
import tty from 'node:tty';
if (process.stdin.isTTY) {
process.stdin.setRawMode(true);
}
Notes
The docs say its value will change with subsequent calls to setRawMode for isRaw; isTTY stays true.
Reference list
tty.ReadStreamis the readable side of a TTY.isTTYis always true for tty.ReadStream instances.setRawModemakes the stream operate as a raw device.
See also
Claims
- id: C1 claim: The module is often unnecessary to use directly. source: S1 evidence: "it will not be necessary or possible to use this module directly"
- id: C2 claim: isTTY is always true for tty.ReadStream instances. source: S1 evidence: "A boolean that is always true for tty.ReadStream instances"
- id: C3 claim: setRawMode makes the stream operate as a raw device. source: S2 evidence: "so that it operates as a raw device"
Sources
- [S1] TTY. Node.js docs. https://nodejs.org/api/tty.html . License: MIT. Accessed 2026-11-18.
- [S2] tty.md. Node.js. https://raw.githubusercontent.com/nodejs/node/main/doc/api/tty.md . License: MIT. Accessed 2026-11-18.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Node.js docs, TTY; Node.js, tty.md. MIT (https://raw.githubusercontent.com/nodejs/node/main/LICENSE). Copyright Node.js contributors. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Node.js docs, TTY; Node.js, tty.md. MIT (https://raw.githubusercontent.com/nodejs/node/main/LICENSE). Copyright Node.js contributors.
Cite this
iinventedlight. 2026. "Node.js tty: terminal streams and raw mode." iinventedlight Library, iil:note:xjwhbn8m, version of 2026-11-18. https://iinventedlight.com/library/notes/node-tty/. License: CC-BY-4.0.
@misc{iil_note_xjwhbn8m,
author = {{iinventedlight}},
title = {{Node.js tty: terminal streams and raw mode}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-18},
url = {https://iinventedlight.com/library/notes/node-tty/},
note = {Permanent ID iil:note:xjwhbn8m. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- node-tty.table.json (table; CC-BY-4.0)
- node-tty.schema.json (schema; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/node-tty.md.