From Coder Merlin
Within these castle walls be forged Mavens of Computer Science ...
— Merlin, The Coder

A picture of Douglas Crockford

What is JSON?[edit]

JSON, also known as JavaScript Object Notation, is a text-based, human-readable data interchange format. The filetype used is .json and is based off of a subset of the JavaScript language. The .json format is completely text-based, and was created back in 2001 by Douglas Crockford. It was later standardized in 2006 through the IETF (Internet Engineering Task Force) under RFC 4627. All modern programming languages also provide support for producing and consuming .json data.

Why use JSON?[edit]

Because the file format is text only, JSON data can be easily sent between computers and implemented in various ways using any programming language. If a programmer wishes to convert JSON back into JavaScript, that is also possible. JSON also makes a neat package for any information sent over the internet or any other connection.

JSON has become widely preferred not only because of these features, but also because it is lightweight, fast, text-based, and an easy-to-parse format needing no extra code or parsing.


Other formats used for storing information include XML and YAML.

  • YAML: Very similar to JSON (a superset). Allows comments, unlike JSON.
  • XML: More feature-rich and complex than JSON. For example, contains metadata, uses nodes, uses schema (user defined constraints), and supports comments.

Uses of JSON[edit]

JSON can do various things, but has a few primary uses:

  • Generating a JSON object from user-inputted data
  • Transferring data between different systems
  • Configuring application data
  • Making complex data models much simpler

JSON is used often for transferring data of a network or the internet. JSON is also used to define objects in the JavaScript language. For example, JSON is used in the following cases:

  • APIs
  • Ajax
  • JavaScript
Going DeeperGoingDeeperIcon.png
Use a tools such as Notepad++ or Visual Studio Code to view files neatly.

JSON Syntax[edit]

Below is a sample of JSON syntax:

  "firstName": "John",
  "lastName": "Smith",
  "isAlive": true,
  "age": 27,
  "address": {
    "streetAddress": "21 2nd Street",
    "city": "New York",
    "state": "NY",
    "postalCode": "10021-3100"
  "phoneNumbers": [
      "type": "home",
      "number": "212 555-1234"
      "type": "office",
      "number": "646 555-4567"
  "children": [],
  "spouse": null

JSON is formatted similar to a dictionary, with key and value pairs.

There are a few key tricks to learning how to read and write in .json files:

  • Curly braces {...} contain objects
  • Square brackets [...] contain arrays
  • Data is stored in name-value pairs separated by a colon, :
  • Every data pair and item in an array are separated by a comma ,
  • JSON property names must be within quotations "..."