JSON basics
What Is JSON? A Beginner's Guide
Learn what JSON is, how JSON objects and arrays work, common JSON data types, and how to format and validate JSON online.
What is JSON?
JSON, short for JavaScript Object Notation, is a lightweight text format for storing and exchanging structured data. It is easy for people to read and easy for software to parse, which makes it common in web APIs, configuration files, and data exports.
Although JSON originated from JavaScript syntax, it is language independent. Applications written in Java, Python, PHP, Go, and many other languages can read and create JSON.
A simple JSON example
Here is a JSON object describing a book:
{
"title": "The Little Prince",
"author": "Antoine de Saint-Exupery",
"year": 1943,
"available": true
}The data is organized as key-value pairs. The key is written in double quotes, followed by a colon and its value.
JSON data types
JSON supports six basic value types:
- String: text inside double quotes.
- Number: an integer or decimal value.
- Boolean: either true or false.
- Null: an intentional empty value.
- Object: a collection of key-value pairs.
- Array: an ordered list of values.
JSON objects and arrays
An object starts with an opening brace and ends with a closing brace. It stores named properties, such as a user profile or product. Arrays use square brackets and store an ordered list of values.
{
"name": "Ada",
"skills": ["Python", "SQL", "JavaScript"]
}Objects and arrays can be nested, allowing JSON to represent both simple settings and deeply structured API responses.
Where is JSON used?
Common uses for JSON include:
- Sending data between a browser and a web server.
- Representing REST API requests and responses.
- Storing application settings and configuration.
- Exporting structured data between tools.
How to format and validate JSON
Valid JSON must use double quotes around property names and strings, separate items with commas, and close every object and array. A missing comma or bracket can make an entire document invalid.
Paste your data into the JSON Beautifier online formatter to make nested content easier to read and catch syntax errors quickly. You can also use the JSON minifier when you need a compact version.
Summary
JSON is a compact, portable way to represent structured data. Once you understand objects, arrays, and the basic value types, you can read most JSON files and work confidently with APIs and data tools.