Zest.

JavaScript: Read a file in Node.js

A short, tested JavaScript example for read a file in node.js. Copy it and adjust the names and paths for your project.

JavaScript
import { readFile, writeFile } from "node:fs/promises";

const text = await readFile("data.txt", "utf8");
await writeFile("out.txt", text.toUpperCase());

Find it in Zest

Search for “javascript read a file in node.js” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.

More JavaScript examples

All JavaScript examples