What is JSON? Last Updated : 08 Dec, 2025 Comments Improve Suggest changes 5 Likes Like Report JSON (JavaScript Object Notation) is a lightweight text-based format for storing and exchanging data. It is easy to read, write, and widely used for communication between a server and a client.JSON stores data in key-value pairs.It is language-independent but derived from JavaScript syntax.JSON data is written in a human-readable format.It supports objects { } and arrays [ ] for data representation.JSON Example XML { "name": "Shubham Verma", "age": 22, "city": "Haryana" } Here,name is a string.age is a number.city is a string.Parsing JSON data in JavaScript and accessing its values JavaScript const jsonStr = '{"name": "Mohit", "age": 30, "city": "New Delhi"}'; // Convert JSON string into JavaScript object const obj = JSON.parse(jsonStr); // Accessing JSON data console.log(obj.name); console.log(obj.age); console.log(obj.city); OutputMohit 30 New Delhi JSON.parse() is used to convert the JSON string into a JavaScript object.The object’s properties (name, age, city) are accessed just like any other JavaScript object.How Does JSON Work?What is JSON?JSON is commonly used to transfer data between a server and a web application. Here's a simple process:The server sends data as a JSON string.The client receives the JSON string and converts it into a native object for use in the application.JSON Array with Objects JavaScript const jsonArr = '[{"name": "Amit", "age": 30}, {"name": "Mohit", "age": 25}, {"name": "Rohit", "age": 35}]'; // Parse JSON array into JavaScript object const obj = JSON.parse(jsonArr); // Accessing array elements console.log(obj[0].name); console.log(obj[1].age); console.log(obj[2].name); OutputAmit 25 Rohit JSON arrays are converted to JavaScript arrays using JSON.parse().Access array items using index, e.g., people[0].name.JavaScript Object to JSON StringConverts a JavaScript object into a JSON string using JSON.stringify(). JavaScript const obj = { name: "Mohit", age: 30, city: "New Delhi" }; // Convert JavaScript object to JSON string const jsonStr = JSON.stringify(obj); console.log(jsonStr); Output{"name":"Mohit","age":30,"city":"New Delhi"} JSON.stringify() converts a JavaScript object into a JSON-formatted string.Useful for sending data to servers or storing it as text.Nested JSON Data JavaScript const nJSON = `{ "a": [ {"fName": "Amit", "lName": "Kumar"}, {"fName": "Sumit", "lName": "Dev"}, {"fName": "Punit", "lName": "Singh"} ] }`; // Parse nested JSON string const obj = JSON.parse(nJSON); // Access nested data console.log(obj.a[0].fName); console.log(obj.a[1].lName); console.log(obj.a[2].fName); OutputAmit Dev Punit JSON can contain objects and arrays nested within each other.Use array indexing and dot notation to access nested data.Applications of JSONWeb APIs: JSON is commonly used to fetch data from RESTful APIs.Configuration Files: Many tools and applications use JSON for storing configuration settings.Data Storage: JSON is used in NoSQL databases like MongoDB.Cross-Language Communication: JSON provides data exchange between different programming environments.Advantages of JSONHuman-Readable: Easy for developers to read and debug.Compact: Uses a simple structure, reducing data size.Fast Parsing: Native support in many languages makes parsing quick.Standard Format: Universally accepted for data exchange. Create Quiz Comment S sahoopratyushkumar3 Follow 5 Improve S sahoopratyushkumar3 Follow 5 Improve Article Tags : JavaScript Web Technologies JSON JavaScript-JSON Explore JavaScript BasicsIntroduction to JavaScript4 min readVariables and Datatypes in JavaScript6 min readJavaScript Operators5 min readControl Statements in JavaScript4 min readArray & StringJavaScript Arrays7 min readJavaScript Array Methods7 min readJavaScript Strings5 min readJavaScript String Methods9 min readFunction & ObjectFunctions in JavaScript5 min readJavaScript Function Expression3 min readFunction Overloading in JavaScript4 min readObjects in JavaScript4 min readJavaScript Object Constructors4 min readOOPObject Oriented Programming in JavaScript3 min readClasses and Objects in JavaScript4 min readWhat Are Access Modifiers In JavaScript ?5 min readJavaScript Constructor Method7 min readAsynchronous JavaScriptAsynchronous JavaScript2 min readJavaScript Callbacks4 min readJavaScript Promise4 min readEvent Loop in JavaScript4 min readAsync and Await in JavaScript2 min readException HandlingJavascript Error and Exceptional Handling6 min readJavaScript Errors Throw and Try to Catch2 min readHow to create custom errors in JavaScript ?2 min readJavaScript TypeError - Invalid Array.prototype.sort argument1 min readDOMHTML DOM (Document Object Model)8 min readHow to select DOM Elements in JavaScript ?3 min readJavaScript Custom Events4 min readJavaScript addEventListener() with Examples9 min readAdvanced TopicsClosure in JavaScript4 min readJavaScript Hoisting6 min readScope of Variables in JavaScript3 min readJavaScript Higher Order Functions7 min readDebugging in JavaScript4 min read Like