Sync:

var fs = require('fs');
var obj = JSON.parse(fs.readFileSync('file', 'utf8'));

Async:

var fs = require('fs');
var obj;
fs.readFile('file', 'utf8', function (err, data) {
  if (err) throw err;
  obj = JSON.parse(data);
});
Answer from mihai on Stack Overflow
๐ŸŒ
HeyNode
heynode.com โ€บ tutorial โ€บ readwrite-json-files-nodejs
Read/Write JSON Files with Node.js | HeyNode
In this tutorial, we are going to look at how to read and write to our customer.json file. ... Accessing files in Node is done with the native module fs, which gives you functions to watch, read, and write files along with many other tools to work with the filesystem.
๐ŸŒ
LogRocket
blog.logrocket.com โ€บ home โ€บ reading and writing json files in node.js: a complete tutorial
Reading and writing JSON files in Node.js: A complete tutorial - LogRocket Blog
November 1, 2024 - In the Node runtime environment, you can use the built-in require function and fs modules to load or read JSON files. Because the require function is available for each module, you donโ€™t need to require it.
๐ŸŒ
GitHub
github.com โ€บ jprichardson โ€บ node-fs-extra โ€บ blob โ€บ master โ€บ docs โ€บ readJson.md
node-fs-extra/docs/readJson.md at master ยท jprichardson/node-fs-extra
Reads a JSON file and then parses it into an object. ... const fs = require('fs-extra') // With a callback: fs.readJson('./package.json', (err, packageObj) => { if (err) console.error(err) console.log(packageObj.version) // => 0.1.3 }) // With ...
Author ย  jprichardson
๐ŸŒ
Stack Abuse
stackabuse.com โ€บ reading-and-writing-json-files-with-node-js
Reading and Writing JSON Files with Node.js
July 8, 2024 - To read the JSON data from the file we can use the Node.js fs module.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ node.js โ€บ how-to-read-and-write-json-file-using-node-js
How to read and write JSON file using Node ? - GeeksforGeeks
July 12, 2025 - We can write data into a JSON file by using the nodejs fs module. We can use writeFile method to write data into a file. ... Example: We will add a new user to the existing JSON file, we have created in the previous example.
๐ŸŒ
DEV Community
dev.to โ€บ tejesh โ€บ nodejs-read-json-file-using-require-vs-fs-module-4f94
NodeJS require() vs fs.readFileSync to read JSON files - DEV Community
May 14, 2020 - Also, do note that when using fs.readFileSync, additionally you have to do JSON.parse after reading the content. // using require directly to read json let data = require('./file.json') // using fs module to read json const fs = require('fs') let data = JSON.parse(fs.readFileSync('file.json', 'utf-8')) Subscribe ยท
๐ŸŒ
GitHub
github.com โ€บ stdlib-js โ€บ fs-read-json
GitHub - stdlib-js/fs-read-json: Read a file as JSON.
var data = readJSON.sync( file, ... 'Package description: %s', data.description ); } } @stdlib/fs-read-file: read the entire contents of a file....
Author ย  stdlib-js
Find elsewhere
๐ŸŒ
Futurestud.io
futurestud.io โ€บ tutorials โ€บ node-js-read-a-json-file
Node.js โ€” Read a JSON File
The @supercharge/fs package comes with a handy Fs.readJson(path) method. the Fs.readJson method reads and parses the content of a JSON file and returns the resolved JavaScript value:
๐ŸŒ
Seanmcp
seanmcp.com โ€บ articles โ€บ read-a-json-file-in-node-js
Read a json file in Node.js โ€“ seanmcp.com
Since we are working with a json file, we can use the global JSON object to read the data. The parse method will convert this Buffer into a usuable JSON object: const fs = require("fs"); fs.readFile("./data.json", (error, data) => error ?
๐ŸŒ
Attacomsian
attacomsian.com โ€บ blog โ€บ nodejs-read-write-json-files
How to read and write JSON files in Node.js
October 1, 2022 - To read the JSON data from the databases.json file by using the fs.readFile() method, just pass in the name of the file, an optional encoding type, and a callback function to receive the file data:
๐ŸŒ
Coding Blocks Blog
blog.codingblocks.com โ€บ 2018 โ€บ reading-json-files-in-nodejs-require-vs-fs-readfile
Reading json files in NodeJS: require() vs fs.readFile()
January 2, 2019 - fs provides both sync and async methods as shown above. If you want to read your JSON file without blocking, then fs.readFile is your only option.
๐ŸŒ
Geshan
geshan.com.np โ€บ blog โ€บ 2024 โ€บ 10 โ€บ nodejs-read-json-file
How to Read a JSON File Using Node.js
October 30, 2024 - Learn how to read a JSON file using Node.js. This post covers reading a JSON file synchronously and asynchronously using the fs module and fs-extra NPM package.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ readjson-function-in-fs-extra-nodejs
readJson() function in fs-extra - NodeJS
Create an asyncReadJsonExample.js and copy-paste the following code snippet into that file. Now, run the following command to run the following code snippet. ... const fs = require('fs-extra') // Reading JSON with a callback: fs.readJson('./package.json', (err, packageObj) => { if (err) console.error(err) console.log(packageObj.version) // => 1.0.0 }) // Reading JSON Promises: fs.readJson('./package.json') .then(packageObj => { console.log(packageObj.version) // => 1.0.0 }) .catch(err => { console.error(err) }) // Reading JSON withasync/await: async function asyncReadJsonExample () { try { const packageObj = await fs.readJson('./package.json') console.log(packageObj.version) // => 1.0.0 } catch (err) { console.error(err) } } asyncReadJsonExample()
๐ŸŒ
Better Stack
betterstack.com โ€บ community โ€บ questions โ€บ using-node-how-to-read-json
Using node.js, How Do I Read a Json File into (Server) Memory? | Better Stack Community
In Node.js, you can read a JSON file into memory using the built-in fs (File System) module to read the file content and then use JSON.parse to parse the JSON data.
๐ŸŒ
CodeSignal
codesignal.com โ€บ learn โ€บ courses โ€บ hierarchical-and-structured-data-formats-in-ts โ€บ lessons โ€บ parsing-json-files-in-typescript-using-nodejs
Parsing JSON Files in TypeScript Using Node.js
The fs.readFile function reads the file with UTF-8 encoding, and the callback function handles errors and data processing. ... To parse the JSON data, we use TypeScript's JSON.parse() function, adding type definitions for clarity and safety.
๐ŸŒ
Medium
medium.com โ€บ @mariokandut โ€บ how-to-read-and-write-json-files-with-node-js-d7733c641aab
How to read and write JSON Files with Node.js? | by Mario Kandut | Medium
May 16, 2021 - We would have to read the JSON data from the file and then parse it to a JavaScript object. ... To read the file we have to provide the relative file path, format (optional), and a callback function to fs.readFile.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ node.js โ€บ node-js-fs-extra-readjson-function
Node.js fs-extra readJson() Function - GeeksforGeeks
July 23, 2025 - // Requiring module import fs from "fs-extra" // File path const file = "file.json"; // Function call // Using callback function fs.readJson(file, (err, object) => { if (err) return console.log(err); console.log(object); });
๐ŸŒ
npm
npmjs.com โ€บ package โ€บ jsonfile
jsonfile - npm
const jsonfile = require('jsonfile') const file = '/tmp/data.json' jsonfile.readFile(file) .then(obj => console.dir(obj)) .catch(error => console.error(error)) options (object, default undefined): Pass in any fs.readFileSync options or set reviver for a JSON reviver.
      ยป npm install jsonfile
    
Published ย  Aug 12, 2025
Version ย  6.2.0
Author ย  JP Richardson
๐ŸŒ
MakeUseOf
makeuseof.com โ€บ home โ€บ programming โ€บ how to read and write json files in node.js
How to Read and Write JSON Files in Node.js
October 30, 2023 - For small JSON files, you can use require to read them synchronously. This method automatically parses JSON files into JavaScript objects. For larger JSON files and in non-blocking scenarios, use fs.readFile to read them asynchronously.