Utilities

util.format()

Creates a formatted string using supported placeholders. Extra values and non-string first arguments follow Node formatting rules; output is not a serialization contract.

Formal Syntax & Structure

nodejs syntaxnodejs
util.format(format[, ...args])

Parameters & Attributes

NameTypeDescription
formatanyFirst value or format string.
argsany[]Additional values.

Return Value

string

Formatted diagnostic text.

Working Example

Example Snippetnodejs
import { format } from "node:util";console.log(format("Count: %d", 4));
Node.js Reference