Skip to main content

What is JSON?

JSON is one of the most important concepts in frontend and web development in general. Simply put:

JSON (JavaScript Object Notation) is a text format for storing and exchanging data, understandable to both humans and computers.


Example of JSON

javascript
{ "name": "Oleh", "age": 25, "isAdmin": false, "skills": ["JavaScript", "React", "Node.js"], "address": { "city": "Kyiv", "zip": 123456 } }

This is a regular JSON document. Essentially it is a string that holds structured data. Such data is easy to read and transmit over the network.


Where JSON is used

  1. Exchanging data between the client and the server The server sends JSON, the browser reads it:
javascript
fetch('/api/user') .then(res => res.json()) .then(data => console.log(data.name));
  1. Storing data in localStorage
javascript
const user = { name: 'Oleh', age: 25 }; localStorage.setItem('user', JSON.stringify(user));
  1. Settings and configuration (for example, package.json in Node.js projects):
javascript
{ "name": "my-project", "version": "1.0.0", "scripts": { "start": "node index.js" } }

JSON syntax rules

RuleDescription
Keys are always in double quotes"name": "Oleh"
Strings are also in double quotes"city": "Kyiv"
Only simple types are supportedstring, number, boolean, null, object, array
No functionsfunction() {} → error
No undefined and Symbolthey are ignored
Comma between elementsbut not after the last element

Basic JSON data types

TypeExample
string"Oleh"
number25
booleantrue, false
nullnull
object{ "a": 1, "b": 2 }
array[1, 2, 3]

Difference between JSON and JavaScript objects

FeatureJSONJavaScript object
KeysOnly in "double quotes"Can be without quotes
StringsOnly "double"'single' or "double"
TypesOnly simple ones (string, number, etc.)Any (function, undefined, symbol)
PurposeStoring/exchanging dataWorking with data in JS code

Converting between an object and JSON

javascript
const obj = { name: 'Oleh', age: 25 }; // object -> JSON const json = JSON.stringify(obj); console.log(json); // '{"name":"Oleh","age":25}' // JSON -> object const parsed = JSON.parse(json); console.log(parsed.name); // 'Oleh'

Summary

ParameterJSON
Full nameJavaScript Object Notation
FormatText
Used forStoring and exchanging data
Typical operationsJSON.stringify() and JSON.parse()
Based onJavaScript syntax
SupportedIn all languages (Python, Java, C#, Go, etc.)

In short

JSON is a universal data format that lets you transmit complex structures (objects, arrays and so on) as a plain text string.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.