fs.stat()
Returns information about a file or directory.
Syntax
await stat(path[, options]) Parameters
| Name | Type | Required | Description |
|---|---|---|---|
path | string | Buffer | URL | Yes | The path to inspect. |
options | object | No | `bigint: true` returns numeric values as BigInt for nanosecond timestamps and large sizes. |
Returns
Promise<Stats> — A Stats object with size, timestamps, and type predicates.
Examples
import { stat } from 'node:fs/promises';
const s = await stat('./package.json');
console.log(s.size, s.isFile());
Output
842 true
import { stat } from 'node:fs/promises';
const s = await stat('./src');
console.log(s.isDirectory(), s.mtime.toISOString());
Output
true 2026-05-15T10:00:00.000Z
Notes
Throws `ENOENT` if the path does not exist; catch it instead of
calling `exists` first to avoid race conditions. Use `lstat` to
inspect a symlink itself rather than its target.