const fs = require("fs"); try { let json = fs.readFileSync("ShareGPT_V4_unfiltered_cleaned_split.json", "utf8"); var obj = JSON.parse(json); console.log("No problem"); } catch (e) { // The JSON was invalid, `e` has some further information console.log(e); }