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
๐ŸŒ
TecAdmin
tecadmin.net โ€บ parse-json-nodejs
How To Parse JSON in Node.js - TecAdmin
April 26, 2025 - This tutorial will help you to read JSON file using Node.js uses readFile and readFileSync functions of the jsonfile module.
Discussions

How do I read a JSON file into (server) memory?
I am doing some experimentation with Node.js and would like to read a JSON object, either from a text file or a .js file (which is better??) into memory so that I can access that object quickly fro... More on stackoverflow.com
๐ŸŒ stackoverflow.com
14-Using Promise to read json file in Node js
0 votes and 0 comments so far on Reddit More on reddit.com
๐ŸŒ r/node
0
March 15, 2014
NodeJS - AutoConvert a Folder with CSV files to an output folder for JSON files
var filePath = path.join(__dirname, '/CSV_FOLDER'); // Read CSV var f = fs.readFileSync(filePath, {encoding: 'utf-8'}, Looks like you are trying to operate on a folder instead of a file. you need to put most of this logic in a loop of the files in the folder. More on reddit.com
๐ŸŒ r/node
17
13
June 29, 2018
How to read big json file?
I have a json file of ~500mb, containing only one big array of numbers. And I want to read that file to use the array in a program. How do I do? I can't use fs.readFileSync because the file is too big. More on reddit.com
๐ŸŒ r/node
2
5
May 11, 2016
๐ŸŒ
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 - you can read json files either using require('filename.json') or fs.readFileSync('filename.json') If the JSON file is static, require() is better because require() caches the file.
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ how-to-read-and-write-files-with-nodejs
How to Read and Write Files with Node.js
August 19, 2024 - It's an asynchronous JavaScript function that takes a filename as input and aims to return the parsed JSON contents of that file. Inside a try block, we attempt to read the file using fs.readFile in Node with the specified filename and "utf8" encoding.
๐ŸŒ
Node.js
nodejs.org โ€บ en โ€บ learn โ€บ manipulating-files โ€บ reading-files-with-nodejs
Node.js โ€” Reading files with Node.js
const fs = require('node:fs/promises'); async function example() { try { const data = await fs.readFile('/Users/joe/test.txt', { encoding: 'utf8' }); console.log(data); } catch (err) { console.error(err); } } example();
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ API โ€บ Fetch_API โ€บ Using_Fetch
Using the Fetch API - Web APIs | MDN
Note that just like response bodies, request bodies are streams, and making the request reads the stream, so if a request contains a body, you can't make it twice: ... const request = new Request("https://example.org/post", { method: "POST", body: JSON.stringify({ username: "example" }), }); const response1 = await fetch(request); console.log(response1.status); // Will throw: "Body has already been consumed." const response2 = await fetch(request); console.log(response2.status);
Find elsewhere
๐ŸŒ
npm
npmjs.com โ€บ package โ€บ nodemon
nodemon - npm
3 weeks ago - If you have a package.json file for your app, you can omit the main script entirely and nodemon will read the package.json for the main property and use that value as the app (ref).
      ยป npm install nodemon
    
Published ย  Feb 20, 2026
Version ย  3.1.14
Author ย  Remy Sharp
Homepage ย  https://nodemon.io
๐ŸŒ
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
const fs = require('fs'); // Specify the path to your JSON file const filePath = 'path/to/your/file.json'; // Read the JSON file fs.readFile(filePath, 'utf8', (err, data) => { if (err) { console.error('Error reading JSON file:', err); return; } // Parse the JSON data try { const jsonData = JSON.parse(data); // Now you have the JSON data in memory console.log('JSON Data:', jsonData); } catch (parseError) { console.error('Error parsing JSON:', parseError); } });
๐ŸŒ
Stack Abuse
stackabuse.com โ€บ bytes โ€บ how-to-import-a-json-file-in-javascript-node-js
How to Import a JSON File in JavaScript/Node.js
September 18, 2023 - Importing a JSON file in Node.js is very easy to do since JSON is a native type to JS. You can use the built-in fs (file system) module to read the file, and then parse it into a JavaScript object using JSON.parse().
๐ŸŒ
W3Schools
w3schools.com โ€บ js โ€บ js_json.asp
W3Schools.com
JSON is used to send, receive and store data. ... Code for reading and generating JSON data can be written in any programming language.
๐ŸŒ
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 - Node doesnโ€™t have a built-in function for appending or updating the fields of an existing JSON file out of the box. However, you can read the JSON file using the readFile method of the fs module, update it, and overwrite the JSON file with ...
๐ŸŒ
Futurestud.io
futurestud.io โ€บ tutorials โ€บ node-js-read-a-json-file
Node.js โ€” Read a JSON File
Node.js provides the fs module to read files from the local hard disk. Use the Fs.readFile to read the content of a given file. Related to a JSON file, youโ€™ll then have the JSON content as a string.
๐ŸŒ
DEV Community
dev.to โ€บ isalevine โ€บ three-ways-to-retrieve-json-from-the-web-using-node-js-3c88
Three Ways to Retrieve JSON from the Web using Node.js - DEV Community
September 1, 2019 - The request package also has a ... no error (and we get a 200 status code back). So, to access the JSON we want, just use the body variable! This readability comes at the price of speed, however....
๐ŸŒ
Oxylabs
oxylabs.io โ€บ blog โ€บ javascript-read-json-file
How to Read JSON Files in JavaScript: Tutorial
We'll cover multiple methods for ... JSON file functionality to import data. In Node.js, the require() function provides functionalities to read and parse JSON files....
๐ŸŒ
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 - A straightforward way to read a JSON file in a Node JS file is by using the `require()` method to include it.
๐ŸŒ
SAP Community
community.sap.com โ€บ t5 โ€บ technology-q-a โ€บ using-node-js-how-do-i-read-a-json-file-into-server-memory โ€บ qaq-p โ€บ 12733981
Using Node.JS, how do I read a JSON file into (ser... - SAP Community
September 29, 2023 - I'm currently engaged in some Node.js experimentation and need to efficiently load a JSON object into memory for quick access. I'm considering whether to read this JSON object from either a text file or a .js file. While I'm aware of tools like Mongo and Alfred, my current requirements do not call f...
๐ŸŒ
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.
๐ŸŒ
Stefan Judis
stefanjudis.com โ€บ snippets โ€บ how-to-import-json-files-in-es-modules-node-js
How to import JSON files in ES modules (Node.js) | Stefan Judis Web Development
May 15, 2025 - The documentation also states that you can use createRequire to load JSON files. This approach is the way Pawel advises in his blog post. createRequire allows you to construct a CommonJS require function to use typical CommonJS features such as reading JSON in your Node.js ECMAScript modules.