JavaScript Object Notation (JSON) is a lightweight, text-based, language-independent data-interchange format. It represents structured values using shared formatting rules rather than transferring a programming language’s native in-memory objects. Although its name comes from JavaScript, programs written in languages including JavaScript, Python and Java can exchange JSON when they have appropriate support.
Values, Objects and Arrays
The permitted values in JavaScript Object Notation (JSON) are objects, arrays, strings, numbers, booleans written as lowercase true or false, and lowercase null. Numbers must follow JSON’s grammar; NaN and Infinity are not permitted. A complete JSON text can represent any permitted value, so 42 or true can stand alone without an enclosing object or array.
An object uses curly braces, {}, to associate string names with values. Its members are an unordered collection: names, rather than position, identify the associated values. An object can be empty, and its values can include further objects or arrays.
An array uses square brackets, [], for an ordered sequence of values. Unlike object member order, array element order is meaningful. Arrays can be empty, mix value types, and contain objects or other arrays. Placing containers inside other containers is called nesting.
A Compact JSON Example
This example of JavaScript Object Notation (JSON) records a person’s name, age, student status, courses and address.
{
"name": "John Doe",
"age": 30,
"isStudent": false,
"courses": ["Math", "Science"],
"address": {
"street": "123 Main St",
"city": "Anytown"
}
}
The outer braces define an object. The name value is the string "John Doe", age is the number 30, and isStudent is the boolean false, not the string "false". The courses array preserves the sequence "Math", then "Science". The address value is a nested object with string-valued street and city members; to find the city, a reader follows address and then city to find "Anytown".
Advertisement — FinchTrade.
FinchTrade services
Get startedBasic Syntax and Validity
Object names and string values require straight double quotation marks, not single or typographic quotes. A colon separates each name from its value, while commas separate object members or array elements. Neither container permits a comma after its final entry.
Spaces, tabs and line breaks can format the document outside strings. Comments outside strings are not part of standard JSON, although comment-like characters inside a quoted string are string content. A permissive parser may accept comments, trailing commas or other extensions, but acceptance alone does not establish JSON validity.
Strings support Unicode characters, which can generally appear directly or through valid escape sequences. Embedded double quotes, backslashes and control characters must be escaped; for example, \n represents a newline within a string.
Exchange, Storage and Limits
Serialization converts supported program data into conforming JSON text. Parsing performs the receiving step: it interprets that text and produces values the receiving program can use. The programs share a textual representation, not necessarily the same internal data structures. JSON is a data format, not a programming language.
A server can return JSON text in an API response, and a web application can parse that body to obtain usable values. This works when the response contains parseable JSON; not every server response does. Server–web application exchange is one use of JavaScript Object Notation, not its defining limit.
Programs can also store serialized JSON in a .json file for later reading and parsing. The extension alone does not establish validity: the file must contain a conforming JSON document. Being text-based does not mean the document represents a string value; it may instead represent an object, array or another permitted value.
For exchange between systems that are not part of a closed ecosystem, RFC 8259 requires JSON text to use UTF-8, a character encoding for Unicode. This shared format does not preserve every native program type automatically. Receiving implementations may also impose limits on document size, nesting depth and numeric range or precision.