Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP W3.CSS C C++ C# HOW TO BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING INTRO TO HTML & CSS BASH RUST TOOLS

JS Tutorial

JS Home JS Introduction JS Where To JS Output JS Syntax JS Operators JS If Conditions JS Loops JS Strings JS Numbers JS Functions JS Timers JS Objects JS Scope JS Dates JS Temporal  New JS Arrays JS Sets JS Maps JS Iterations JS Math JS RegExp JS Data Types JS Errors JS Debugging JS Style Guide JS Reference JS Projects  New JS Versions JS HTML DOM JS HTML Events JS HTML First

JS Advanced

JS Functions JS Objects JS Classes JS JSON JS Asynchronous JS Modules JS Meta & Proxy JS Typed Arrays JS DOM Navigation JS Browser API JS Web API JS Graphics

Old Technologies

JS AJAX JS jQuery JS JSONP

JS Examples

JS Examples

JavaScript JSON Values

JSON can represent six types of values.

A JSON value can be a string, number, boolean, null, object, or array.


JSON Value Types

The table below lists all JSON value types.

Type Example
String "John"
Number 30
Boolean true
Null null
Object {"name":"John"}
Array ["red","green"]

JSON Strings

A JSON string is a sequence of characters enclosed in double quotes.

Example

{
  "name": "John"
}

JSON strings always use double quotes.


JSON Numbers

JSON numbers can be integers or floating-point numbers.

Example

{
  "age": 30,
  "height": 1.82
}

JSON does not distinguish between integers and floating-point numbers.


JSON Booleans

JSON supports the Boolean values true and false.

Example

{
  "member": true,
  "student": false
}

JSON Null

The value null represents an empty value.

Example

{
  "middleName": null
}

JSON Objects

A JSON object is enclosed in curly braces.

A JSON object contains one or more name/value pairs.

Example

{
  "name": "John",
  "age": 30,
  "city": "New York"
}

Names must be strings enclosed in double quotes.

Values can be any valid JSON value.



JSON Arrays

A JSON array is enclosed in square brackets.

An array contains an ordered list of values.

Example

[
  "Ford",
  "Volvo",
  "BMW"
]

Array values can be any valid JSON value.


Nested Values

Objects and arrays can contain other objects and arrays.

Example

{
  "name": "John",
  "age": 30,
  "address": {
    "city": "New York",
    "country": "USA"
  },
  "hobbies": [
    "Reading",
    "Cycling",
    "Photography"
  ]
}

Nested objects and arrays make it possible to represent complex data structures.


Unsupported Values

Some JavaScript values cannot be represented in JSON.

JavaScript Value Supported in JSON
undefined No
Functions No
Symbol No
BigInt No
NaN No
Infinity No

These values must be converted before they can be stored as JSON.



×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2026 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.

-->