Buffer
buffer.isAscii()
Checks whether every byte is in the ASCII range. It accepts control bytes too, so validate printable text separately. Tested on Node.js 22.16.0. Example output (one line per entry): ["true false"].
Formal Syntax & Structure
nodejs syntaxnodejs
isAscii(input)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| input | Buffer | TypedArray | ArrayBuffer | Input bytes. |
Return Value
boolean
ASCII validity.
Working Example
Example Snippetnodejs
import { isAscii } from 'node:buffer';console.log(isAscii(Buffer.from([0, 127])), isAscii(Buffer.from('é')));