{"id":90861,"date":"2025-10-23T11:32:47","date_gmt":"2025-10-23T06:02:47","guid":{"rendered":"https:\/\/www.guvi.in\/blog\/?p=90861"},"modified":"2026-09-19T12:48:24","modified_gmt":"2026-09-19T07:18:24","slug":"complete-guide-on-how-to-open-a-json-file","status":"publish","type":"post","link":"https:\/\/www.guvi.in\/blog\/complete-guide-on-how-to-open-a-json-file\/","title":{"rendered":"How to Open a JSON File in 2026: Windows, Mac, Online &#038; Code Editors"},"content":{"rendered":"\n<p><strong>Quick Answer:<\/strong><\/p>\n\n\n\n<p>To open a JSON file, right-click it and choose a text editor.<\/p>\n\n\n\n<ul>\n<li><strong>Windows:<\/strong> Open with Notepad for plain text, or VS Code for a color-coded view.<\/li>\n\n\n\n<li><strong>Mac:<\/strong> Open with TextEdit for plain text, or VS Code for better readability.<\/li>\n\n\n\n<li><strong>Online:<\/strong> Upload the file to a JSON editor website to view it in a structured, validated format.<\/li>\n\n\n\n<li><strong>Code editors:<\/strong> Use VS Code, Atom, or Sublime Text for syntax highlighting and easy navigation through nested data.<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<p>Knowing how to open a JSON file the right way saves you from staring at an unreadable block of text. The result depends entirely on the tool you use, since the same file can look like plain text in one app and a structured, colour-coded view in another.<\/p>\n\n\n\n<p>This guide covers every practical way to open a JSON file in 2026, on Windows, Mac, online, or inside a code editor, so you can pick the method that actually fits what you need to do with the file.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<div style=\"background-color: #099f4e; border: 3px solid #110053; border-radius: 12px; padding: 18px 22px; color: #FFFFFF; font-size: 18px; font-family: Montserrat, Helvetica, sans-serif; line-height: 1.6; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); max-width: 750px;\">\n  <strong style=\"font-size: 22px; color: #ffffff;\">\ud83d\udca1 Did You Know?<\/strong> <br \/><br \/>\n  <span>\n    <strong style=\"color: #110053;\">JSON<\/strong> was created by <strong style=\"color: #110053;\">Douglas Crockford<\/strong> in <strong style=\"color: #110053;\">2001<\/strong> as a lightweight, language-independent format for exchanging data and is now used in almost all programming languages.\n  <\/span>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What Is a JSON File?<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"630\" src=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/01@2-1200x630.webp\" alt=\"\" class=\"wp-image-135253\" srcset=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/01@2-1200x630.webp 1200w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/01@2-300x157.webp 300w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/01@2-768x403.webp 768w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/01@2-1536x806.webp 1536w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/01@2-150x79.webp 150w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/01@2.webp 2048w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" title=\"\"><\/figure>\n\n\n\n<p><strong>JSON (JavaScript Object Notation)<\/strong> is a light-weight data format that <strong>stores and transmits data objects in human-readable text<\/strong>. It organizes and structures the data using <strong>key-value pairs and <\/strong><a href=\"https:\/\/www.guvi.in\/blog\/guide-for-arrays-in-javascript\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>arrays<\/strong><\/a>, making it easier for both humans and machines to comprehend.<\/p>\n\n\n\n<p>A <strong>JSON file<\/strong> is a collection of data and information in a simple text format, allowing users to view the data as objects. <a href=\"https:\/\/www.guvi.in\/blog\/objects-methods-and-classes-in-javascript\/\" target=\"_blank\" rel=\"noreferrer noopener\">Objects<\/a> have properties, and these properties can contain information in the form of an array of objects.&nbsp;<\/p>\n\n\n\n<p>JSON files are widely used to transfer data between applications, APIs, and servers, enabling strong connectivity among different components in the software architecture. <\/p>\n\n\n\n<p>These files use little memory or storage, are easy to read and write, and require minimal resources. This simplicity and broad compatibility make JSON files an essential part of modern app development.<\/p>\n\n\n\n<p><strong>Vital Information:<\/strong> <em>We use JavaScript as our primary language to explain the JSON examples below. <\/em><strong><em>Developers <\/em><\/strong><em><strong>can use any programming language, <\/strong>such as Python, Java, C#, or PHP, to work with JSON.<\/em><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Also Read: <\/strong><em><a href=\"https:\/\/www.guvi.in\/blog\/handling-json-datetime-between-python-and-javascript\/\" target=\"_blank\" rel=\"noreferrer noopener\">Handling JSON Datetime Between Python and JavaScript<\/a><\/em><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong><em>Go beyond the basics with HCL GUVI&#8217;s <\/em><\/strong><em><a href=\"https:\/\/www.guvi.in\/zen-class\/full-stack-development-course?utm_source=blog&amp;utm_medium=hyperlink&amp;utm_campaign=complete-guide-on-how-to-open-a-json-file\" target=\"_blank\" rel=\"noreferrer noopener\">Software and AI Engineer Course<\/a><\/em><strong><em>; master React, Node.js, REST APIs, and MongoDB while building real full-stack applications. Learn DSA, System Design, and AI-integrated development from industry mentors, with placement support from 1000+ hiring partners. Enroll today and build the skills top tech companies actually hire for!<\/em><\/strong><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to Create a JSON File<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"630\" src=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/02@2-1200x630.webp\" alt=\"\" class=\"wp-image-135254\" srcset=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/02@2-1200x630.webp 1200w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/02@2-300x157.webp 300w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/02@2-768x403.webp 768w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/02@2-1536x806.webp 1536w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/02@2-150x79.webp 150w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/02@2.webp 2048w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" title=\"\"><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>const fs = require('fs').promises;\n\nconst data = {\n\n    name: \"Abhishek\",\n\n    age: 25,\n\n    skills: &#91;\"JavaScript\", \"React\", \"Node.js\"]\n\n};\n\nasync function createJSONFile() {\n\n    try {\n\n        await fs.writeFile('data.json', JSON.stringify(data, null, 4));\n\n        console.log(\"JSON file created successfully!\");\n\n    } catch (err) {\n\n        console.error(\"Error writing file:\", err);\n\n    }\n\n}\n\ncreateJSONFile();\n<\/code><\/pre>\n\n\n\n<p><strong><em>Explanation:<\/em><\/strong><\/p>\n\n\n\n<ul>\n<li>Here, we <span style=\"box-sizing: border-box; margin: 0px; padding: 0px;\">use the&nbsp;<strong>fs (file system) module<\/strong>, a built-in Node.js library, to let<strong>&nbsp;JavaScript<\/strong>&nbsp;<\/span>interact with the computer&#8217;s file system.<\/li>\n<\/ul>\n\n\n\n<ul>\n<li><strong>const fs = require(&#8216;fs&#8217;).promises.<\/strong> This line loads the fs module with promises in Node.js, allowing us to <span style=\"box-sizing: border-box; margin: 0px; padding: 0px;\">use\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/Async\/await\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">async\/await<\/a>\u00a0instead of\u00a0<\/span>callbacks.\u00a0\u00a0\u00a0<\/li>\n<\/ul>\n\n\n\n<ul>\n<li>Now, in this case, we have created a data variable and initialized it with an object that contains the following information in key-value pairs, such as <strong>&#8220;name&#8221;: &#8220;Abhishek&#8221;, &#8220;age&#8221;: 25, and &#8220;skills&#8221;: [&#8220;JavaScript&#8221;, &#8220;React&#8221;, &#8220;Node.js&#8221;].&nbsp;&nbsp;&nbsp;<\/strong><\/li>\n<\/ul>\n\n\n\n<ul>\n<li>But remember that data can be stored in a JSON file as text only, which is why we used <strong>JSON.stringify(data, null, 4) <\/strong>method to convert the data object into a <strong>JSON-formatted string<\/strong>. Inside this function, the null parameter is used to modify keys, but since we don&#8217;t want that, we set it to null. The last parameter is set to 4 for indentation, making the JSON file readable instead of a long line.<\/li>\n<\/ul>\n\n\n\n<ul>\n<li><span style=\"box-sizing: border-box; margin: 0px; padding: 0px;\">You can see the&nbsp;<strong>createJSONFile()&nbsp;<\/strong>function, which <span style=\"box-sizing: border-box; margin: 0px; padding: 0px;\">performs an&nbsp;<a href=\"https:\/\/www.guvi.in\/blog\/asynchronous-operations-in-javascript\/\" target=\"_blank\" rel=\"noopener\">asynchronous operation<\/a>&nbsp;to create a new JSON file&nbsp;<strong>(<\/strong><\/span><strong>data.json()<\/strong>&nbsp;and write the JSON string into it.<\/span> Here, the await keyword tells the JS code to wait for the create operation to complete before moving on. Additionally, errors are handled using a<strong> try\/catch<\/strong> block. Finally, we have invoked the function.<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<p><strong><em>Explore our free resources to delve deep into the concepts of JavaScript:<\/em><\/strong>\u00a0<a href=\"https:\/\/www.guvi.in\/mlp\/js-ebook?utm_source=blog&amp;utm_medium=hyperlink&amp;utm_campaign=complete-guide-on-how-to-open-a-json-file\" target=\"_blank\" rel=\"noreferrer noopener\">JS eBook<\/a><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to Open a JSON File<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"630\" src=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/03@2-1200x630.webp\" alt=\"\" class=\"wp-image-135258\" srcset=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/03@2-1200x630.webp 1200w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/03@2-300x157.webp 300w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/03@2-768x403.webp 768w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/03@2-1536x806.webp 1536w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/03@2-150x79.webp 150w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/03@2.webp 2048w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" title=\"\"><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1. Opening a JSON File on Windows:<\/strong><\/h3>\n\n\n\n<p>Opening a JSON file on Windows is simple. You just have to <strong>right-click the file, choose the &#8220;Open with&#8221; option,<\/strong> and then select either <strong>Notepad <\/strong>or <strong>VS Code<\/strong>. Notepad opens the JSON file as plain text, while VS Code shows the data in coloured syntax, making the structure easier to understand.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. Opening JSON File on Mac:<\/strong><\/h3>\n\n\n\n<p>Similar to Windows, to open a JSON file on macOS, <strong>right-click it and select the &#8220;Open With&#8221; option<\/strong>. The only difference is that instead of Notepad, you&#8217;ll see TextEdit to view JSON as plain text, while VS Code offers better readability.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. Opening JSON File Online:<\/strong><\/h3>\n\n\n\n<p>To open a JSON file online, you can visit websites like<a href=\"https:\/\/jsoneditoronline.org\/#right=local.zehiso\" target=\"_blank\" rel=\"noreferrer noopener nofollow\"> <strong><em>json-editor-online<\/em><\/strong><\/a>. You only need to upload your JSON file or paste the content, and the platform will display it in a well-structured, easy-to-read format. In these kinds of sites, along with opening and editing the JSON files, you can also validate them.<\/p>\n\n\n\n<p><strong>Note:<\/strong> You can also use a browser extension like <code>JSON Formatter<\/code> for Chrome \u2014 it automatically turns raw JSON into a clean, readable tree view whenever you open a <code>.json<\/code> file or API response directly in your browser.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>4. Opening JSON File in Code Editors:<\/strong><\/h3>\n\n\n\n<p><span style=\"box-sizing: border-box; margin: 0px; padding: 0px;\">Multiple code editors, such as&nbsp;<strong>VS Code, Atom, Sublime Text<\/strong>, and more,&nbsp;<\/span>help users open JSON files. These powerful tools highlight the syntax and elements within the JSON file interactively and colorfully, automatically indent the data, and enable navigation through nested structures. Opening JSON files in code editors benefits developers who frequently read or edit them.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Which Tool Should You Use to Open a JSON File?<\/strong><\/h2>\n\n\n\n<p>The right tool depends on your device and what you plan to do with the data.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th><strong>Platform<\/strong><\/th><th><strong>Tool<\/strong><\/th><th><strong>Best For<\/strong><\/th><th><strong>View Type<\/strong><\/th><\/tr><\/thead><tbody><tr><td><strong>Windows<\/strong><\/td><td>Notepad<\/td><td>Quick, no-setup viewing<\/td><td>Plain text<\/td><\/tr><tr><td><strong>Windows<\/strong><\/td><td>VS Code<\/td><td>Reading and editing with clarity<\/td><td>Colored syntax<\/td><\/tr><tr><td><strong>Mac<\/strong><\/td><td>TextEdit<\/td><td>Quick, no-setup viewing<\/td><td>Plain text<\/td><\/tr><tr><td><strong>Mac<\/strong><\/td><td>VS Code<\/td><td>Reading and editing with clarity<\/td><td>Colored syntax<\/td><\/tr><tr><td><strong>Online<\/strong><\/td><td>JSON editor websites<\/td><td>Viewing without installing anything<\/td><td>Structured + validated<\/td><\/tr><tr><td><strong>Code Editors<\/strong><\/td><td>VS Code, Atom, Sublime Text<\/td><td>Frequent editing, nested JSON structures<\/td><td>Interactive, color-coded<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>Important Note:<\/strong><\/p>\n\n\n\n<ul>\n<li>If you just need to glance at a JSON file once, Notepad or TextEdit will do.<\/li>\n\n\n\n<li>If you&#8217;re a developer working with JSON regularly, a code editor like VS Code is worth the extra step \u2014 it saves time on formatting and catches errors early.<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to Read a JSON File<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"630\" src=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/04@2x-1200x630.webp\" alt=\"\" class=\"wp-image-135259\" srcset=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/04@2x-1200x630.webp 1200w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/04@2x-300x157.webp 300w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/04@2x-768x403.webp 768w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/04@2x-1536x806.webp 1536w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/04@2x-150x79.webp 150w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/04@2x.webp 2048w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" title=\"\"><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>const fs = require('fs');\n\n\/\/ Read JSON file\n\nfs.readFile('data.json', 'utf-8', (err, jsonString) =&gt; {\n\n    if (err) {\n\n        console.log(\"File read failed:\", err);\n\n        return;\n\n    }\n\n    try {\n\n        const data = JSON.parse(jsonString);      \/\/ Convert JSON string to JS object\n\n        console.log(data);\n\n        console.log(\"Name:\", data.name);\n\n        console.log(\"Skills:\", data.skills);\n\n    } catch (err) {\n\n        console.log(\"Error parsing JSON:\", err);\n\n    }\n\n});\n<\/code><\/pre>\n\n\n\n<p><strong><em>Explanation:<\/em><\/strong><\/p>\n\n\n\n<ul>\n<li>We <span style=\"box-sizing: border-box; margin: 0px; padding: 0px;\">imported the<strong>&nbsp;fs (File System) module&nbsp;<\/strong>because it lets us&nbsp;<\/span>read, write, and manage files. Inside this module, readFile is a function we access as <strong>fs.readFile<\/strong>. <\/li>\n\n\n\n<li>It is an asynchronous function that reads the content of the JSON file <strong>(data.json)<\/strong> without blocking the main <a href=\"https:\/\/www.guvi.in\/blog\/is-javascript-single-threaded-or-multi-threaded\/\" target=\"_blank\" rel=\"noreferrer noopener\">JS<strong> <\/strong>thread<\/a> and returns the content as a text string through a callback <strong>((err, jsonString) =&gt; { &#8230; })<\/strong>.<\/li>\n<\/ul>\n\n\n\n<ul>\n<li>In this code statement,<strong> &#8216; fs.readFile(&#8216;data.json&#8217;, &#8216;utf-8&#8217;, (err, jsonString) =&gt; { &#8230; }) <\/strong><span style=\"box-sizing: border-box; margin: 0px; padding: 0px;\"><strong>&#8216;<\/strong>,<\/span> we are calling the function and asking Node.js to read the data.json file. <span style=\"box-sizing: border-box; margin: 0px; padding: 0px;\">The second parameter&nbsp;<strong>&#8216;utf-8&#8217;&nbsp;<\/strong>specifies the encoding to decode the file bytes into a <a href=\"https:\/\/www.guvi.in\/blog\/what-are-javascript-strings\/\" target=\"_blank\" rel=\"noreferrer noopener\">string<\/a> using&nbsp;<strong>UTF-8 encoding<\/strong>.<\/span> Without UTF-8 encoding, we would get the raw binary data.<\/li>\n<\/ul>\n\n\n\n<ul>\n<li>The third parameter is a <a href=\"https:\/\/www.guvi.in\/blog\/callback-function-in-javascript\/\" target=\"_blank\" rel=\"noreferrer noopener\">callback function<\/a> with two parameters: <strong>err<\/strong> (to detect <a href=\"https:\/\/www.guvi.in\/blog\/error-handling-and-logging-in-mern-stack\/\" target=\"_blank\" rel=\"noreferrer noopener\">errors<\/a>) and <strong>jsonString <\/strong>(to hold the JSON content as a text string).<\/li>\n<\/ul>\n\n\n\n<ul>\n<li>Inside this callback, we first use an if condition to check for reading errors, such as when the file doesn&#8217;t exist or lacks permissions. Then we <span style=\"box-sizing: border-box; margin: 0px; padding: 0px;\">use a&nbsp;<strong>try&#8230;catch<\/strong>&nbsp;block to handle<\/span> JSON parsing.<\/li>\n<\/ul>\n\n\n\n<ul>\n<li><span style=\"box-sizing: border-box; margin: 0px; padding: 0px;\">Here, we have&nbsp;<strong>converted the JSON string to a JS object<\/strong>.<\/span> If any error occurs in the JSON file, such as missing commas, incorrect data types, or incorrect quotes, we wrap the code in a<strong> try\/catch <\/strong>block. If parsing succeeds, we can print the data object to the console; if it fails, we can log an error message.<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to Edit a JSON File<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"630\" src=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/05@2x-1200x630.webp\" alt=\"\" class=\"wp-image-135260\" srcset=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/05@2x-1200x630.webp 1200w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/05@2x-300x157.webp 300w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/05@2x-768x403.webp 768w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/05@2x-1536x806.webp 1536w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/05@2x-150x79.webp 150w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/05@2x.webp 2048w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" title=\"\"><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>const fs = require('fs');\n\n\/\/ Read JSON file\n\nfs.readFile('data.json', 'utf-8', (err, jsonString) =&gt; {\n\n    if (err) {\n\n        console.log(\"File read failed:\", err);\n\n        return;\n\n    }\n\n    try {\n\n        const data = JSON.parse(jsonString);   \/\/ Convert JSON string to JS object\n\n        \/\/ Modify the object\n\n        data.age = 26;\n\n        data.skills.push(\"Node.js\");\n\n        \/\/ Save updated object back to JSON file\n\n        fs.writeFile('data.json', JSON.stringify(data, null, 4), (err) =&gt; {\n\n            if (err) throw err;\n\n            console.log(\"JSON file updated successfully!\");\n\n        });\n\n    } catch (err) {\n\n        console.log(\"Error parsing JSON:\", err);\n\n    }\n\n});\n<\/code><\/pre>\n\n\n\n<p><strong><em>Explanation:<\/em><\/strong><\/p>\n\n\n\n<ul>\n<li>To modify the object in memory in this example, we have used the push method <strong>(data.skills).push(&#8220;Node.js&#8221;)<\/strong> for adding the property to the existing skills array, and also directly updated the age property by specifying a new number<strong> (data.age = 26)<\/strong>.<\/li>\n<\/ul>\n\n\n\n<ul>\n<li>After modifying the object, you need to <strong>save the changes back to the file<\/strong>. This is done with <strong>fs.writeFile(&#8216;data.json&#8217;, JSON.stringify(data, null, 4), (err) =&gt; { &#8230; })<\/strong>.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Best Practices for Working with JSON Files<\/strong><\/h2>\n\n\n\n<p>The following are the best practices while working with the JSON files:<\/p>\n\n\n\n<ul>\n<li><strong>Validate JSON<\/strong> \u2013 Check formatting before parsing.<\/li>\n<\/ul>\n\n\n\n<ul>\n<li><strong>Use UTF-8 encoding<\/strong> \u2013 Ensures readable text, not raw bytes.<\/li>\n<\/ul>\n\n\n\n<ul>\n<li><strong>Handle errors<\/strong> \u2013 Always catch parsing and file I\/O errors.<\/li>\n<\/ul>\n\n\n\n<ul>\n<li><strong>Stringify with indentation<\/strong> \u2013 Makes JSON human-readable.<\/li>\n<\/ul>\n\n\n\n<ul>\n<li><strong>Avoid unsupported data<\/strong> \u2013 Only use strings, numbers, booleans, arrays, objects, or null.<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p>Today, we learned how to create, read, and edit JSON files in JavaScript; understood the difference between JSON as a string in files and JavaScript objects in memory; explored error handling and common JSON mistakes; and discussed modern async\/await methods and best practices for working with JSON efficiently and safely.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>FAQs<\/strong><\/h2>\n\n\n<div id=\"rank-math-faq\" class=\"rank-math-block\">\n<div class=\"rank-math-list \">\n<div id=\"faq-question-1787298813337\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">1. Can I open a JSON file with Notepad?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Yes. Right-click the file, choose &#8220;Open with,&#8221; and select Notepad. It&#8217;ll show as plain text.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1787298820555\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">2. What program opens JSON files by default?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Most systems don&#8217;t have a default program. You choose how to open a JSON file \u2014 usually a text editor or browser.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1787298821697\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">3. Can I open a JSON file in Excel?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Yes, but you&#8217;ll need to import it through Excel&#8217;s &#8220;Get Data&#8221; or Power Query feature \u2014 it won&#8217;t open directly like a text file.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1787298822585\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">4. Do I need special software to open a JSON file?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>No. Since JSON is plain text, any text editor or browser can open it. Special tools just make it easier to read.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1787298826313\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">5. Why does my JSON file look messy when I open it?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>It&#8217;s likely &#8220;minified&#8221; (no spacing). Use a code editor or online JSON formatter to make it readable.<\/p>\n\n<\/div>\n<\/div>\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Quick Answer: To open a JSON file, right-click it and choose a text editor. Knowing how to open a JSON file the right way saves you from staring at an unreadable block of text. The result depends entirely on the tool you use, since the same file can look like plain text in one app [&hellip;]<\/p>\n","protected":false},"author":64,"featured_media":135251,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[907,429],"tags":[],"views":"4574","authorinfo":{"name":"Abhishek Pati","url":"https:\/\/www.guvi.in\/blog\/author\/abhishek-pati\/"},"thumbnailURL":"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/10\/How-to-Open-a-JSON-File-1-300x116.webp","_links":{"self":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/90861"}],"collection":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/users\/64"}],"replies":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/comments?post=90861"}],"version-history":[{"count":35,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/90861\/revisions"}],"predecessor-version":[{"id":139618,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/90861\/revisions\/139618"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/media\/135251"}],"wp:attachment":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/media?parent=90861"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/categories?post=90861"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/tags?post=90861"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}