util.promisify turns a Node.js callback-style function into one that returns a promise, so you can use it with await. It works on functions that take a final error-first callback, written as (err, value) => {}. You call const fn = promisify(original) and then await fn(args).
Today most core modules already ship promise versions, for example node:fs/promises, so util.promisify matters most for older libraries and your own callback code. Examples target Node.js 22 or 24 LTS.
promisify returns a new function that calls the original with your arguments plus a callback it supplies. If the callback receives an error as its first argument, the promise rejects with it. Otherwise the promise resolves with the second argument. The original function is left unchanged.
The function must follow the Node convention: the callback is last, and its first argument is the error or null.
A function that does not call its callback in the error-first form, for example one that calls callback(result) with the value first, will not work correctly. Rewrite it or write a manual wrapper.
If the function is a method that uses this, promisifying it detaches it from its object:
Bind the result to the object, or wrap the call in an arrow function. This is the most common reason a promisified method throws a "cannot read properties of undefined" error.
promisify resolves with only the first value after the error. A callback like callback(null, a, b) would lose b. Some core functions solve this with a custom symbol, util.promisify.custom, which lets the author define the promise version. You can do the same for your own function:
For a simple one-off, writing new Promise((resolve, reject) => ...) by hand is just as clear.
Before reaching for promisify, check whether a promise API already exists:
| Task | Promise version |
|---|---|
| File system | node:fs/promises |
| Timers | setTimeout from node:timers/promises |
| DNS | node:dns/promises |
| Streams helpers | pipeline from node:stream/promises |
| Child processes | util.promisify(execFile) |
exec and execFile from node:child_process are good uses of promisify, because the promise version resolves with an object holding stdout and stderr. The opposite tool is util.callbackify, which turns a function returning a promise into a callback-style one, useful when an old API expects callbacks.
Only functions whose last parameter is an error-first callback. Functions that return a value directly or use other callback shapes need a manual wrapper.
The method lost its object when you passed it as a plain function. Use promisify(obj.method).bind(obj) or call it inside an arrow function.
Usually not. Import from node:fs/promises instead, which is built to return promises and supports the same operations.
No. If the original never calls its callback, the promise stays pending forever, so add a timeout when the source is unreliable.
util.promisify wraps an error-first callback function so it returns a promise you can await. Remember to bind methods, expect only the first result value unless a custom promisify exists, and prefer built-in promise APIs such as node:fs/promises when available.