JSON and YAML flashcards
The two text formats for data and config you will meet everywhere.
What are JSON and YAML, in one plain sentence?
They are two ways to write data as plain text so both people and programs can read it: JSON uses braces and quotes, YAML uses line breaks and spaces.
Tap to turn over. Swipe right if you know it, left to see it again.
What you will learn
Start from zero
- What JSON and YAML are and why they exist4 cards
- Key words: keys, values, objects and arrays4 cards
- Getting started: your first reads4 cards
Core basics
- JSON syntax and common errors4 cards
- JSON types, strings and comments4 cards
- YAML syntax: lists, nesting and comments5 cards
- JSON in code and in the terminal3 cards
Next steps
- YAML scalars and type surprises4 cards
- Block scalars and flow style3 cards
- Reuse, multiple documents and JSON compatibility3 cards
- Command line tools: jq and yq3 cards
- Safe parsing, big numbers, dates and logs4 cards
Go deeper
- Schema validation4 cards
- YAML tags, duplicate keys and parser attacks4 cards
- JSON Pointer and JSON Patch2 cards
- Large files, serialisation and canonical form4 cards
- Choosing formats and CI checks3 cards
Final test and certificate
10 questions drawn fresh from the whole topic, about 15 minutes. Sign in, score 80% or more and get a free certificate with your name and a public check link anyone can open, such as an employer or a teacher. Not signed in? Try a practice test from the cards.
Take the final testAbout these cards
- Reviewed 26 October 2026
- CoversJSON (RFC 8259, ECMA-404 2nd edition)YAML 1.2.2JSON Schema 2020-12jq 1.8yq v4 (Go)
Checked against
JSON and YAML at a glance
JSON and YAML are two ways to write data as plain text that both people and programs can read.
Like a filled-in form: each label has an answer, written either in neat boxes (JSON) or as a tidy list (YAML).
Words you will meet
- Key
- The label part of a piece of data, like name
- Value
- What the label holds, like Karthik or 31
- Object
- A group of keys and values inside curly braces
- Array
- An ordered list inside square brackets
- String
- Text, written inside quotes
- Boolean
- A yes or no value: true or false
- Indentation
- Spaces at the start of a line that show nesting
- Parse
- When a program reads text and turns it into data
The steps
- 1. Start from zero (12 cards): What JSON and YAML are, the words you need, and your first file in each.
- 2. Core basics (16 cards): Write valid JSON and YAML by hand, spot the errors parsers reject, and read both in code.
- 3. Next steps (17 cards): YAML type traps, multi-line strings, anchors, big numbers, dates and the jq and yq tools.
- 4. Go deeper (17 cards): JSON Schema, YAML tags and safety, patches, streaming, serialisation edge cases and format choices.
All 12 cards in Start from zero
- What are JSON and YAML, in one plain sentence?
- They are two ways to write data as plain text so both people and programs can read it: JSON uses braces and quotes, YAML uses line breaks and spaces.
- What was the problem before shared formats like these?
- Every program made up its own file layout, so sharing data meant writing special code for each pair of programs. A common format lets any program read any other's data.
- Where do you already meet JSON and YAML in daily life?
- Your weather app gets today's forecast from a server as JSON. Settings files in apps and games, and the setup files of many websites, are JSON or YAML.
- What everyday thing are they like?
- A filled-in form with labelled boxes: 'Name: Karthik', 'City: Salem'. JSON is the form in neat ink with every box drawn; YAML is the same form as a tidy list.
- What are a 'key' and a 'value', and what kinds of value are there?
- A key is the label and a value is what it holds, as in
"city": "Salem". A value can be a string (text in quotes), a number, a boolean (trueorfalse) ornull(empty on purpose). - What are an 'object' and an 'array'?
- An object is a group of key and value pairs inside curly braces
{}, like one contact card. An array is an ordered list inside square brackets[], like a shopping list. - What are 'indentation' and a 'comment'?
- Indentation is spaces at the start of a line that show one thing sits inside another; YAML depends on it. A comment is a note for humans that programs ignore: YAML starts one with
#, and plain JSON has none. - What do 'parse', 'config' and 'API' mean?
- To parse is for a program to read the text and turn it into data it can use. A config is a settings file, and an API is the doorway an app uses to ask a server for data, which usually answers in JSON.
- What do you need before starting?
- A text editor (an app for plain text, like Notepad or VS Code) and a browser. Nothing to install; later cards use a terminal, the window where you type commands, and a little JavaScript or Python.
- Your first tiny win: read this JSON.
- An object with three keys.
"Karthik"is a string,31is a number andtrueis a boolean; every key sits in double quotes. - The same person in YAML: what changed?
- Each line is a key, a colon and a space, then the value. No braces, and simple text needs no quotes.
- What will you be able to do after this topic?
- Write valid JSON and YAML by hand, spot the mistakes that break them, turn one into the other, and read and write both from code.
JSON and YAML cheatsheet
JSON rules
{ "key": "value" }Object, keys in double quotes[1, "two", null]Array of any valuestrue / false / nullLower case only-12.5e3Number: noNaN,Infinityor leading zeros"\n \" \\ \u00e9"String escapesno trailing commaLast item has no commano commentsUse JSONC or JSON5 if you need them
YAML syntax
key: valueMapping (space after colon)- itemList itemrun: |Literal block, keeps newlinestext: >-Folded block, strip final newlinebase: &baseAnchor a node<<: *baseMerge an anchored map---Start a new documentzip: !!str 01234Force a type with a tag
YAML traps to quote
country: "NO"yes/no/on/offare booleans in 1.1version: "3.10"Else float3.1mode: "0755"Else octal493in 1.1time: "12:30"Else base-60 number in 1.1color: "#fff"Else a comment, value nulltitle: "Note: read"Colon space starts a mapping
In code
JSON.parse(text, reviver)Text to value, transform on the wayJSON.stringify(v, null, 2)Pretty-print with 2 spacesJSON.stringify(v, ["id", "name"])Only these keystoJSON() { return {...} }Control a class's outputstructuredClone(v)Deep copy that keeps Dates and Mapsyaml.safe_load(f) # PythonSafe YAML parsing
Command line
jq . file.jsonValidate and pretty-printjq -r '.items[].id'Raw values from an arrayjq 'select(.qty > 5)'Filter objectsjq -s '.' events.jsonlJSON Lines into one arrayyq -i '.spec.replicas = 3' d.yamlEdit YAML in placeyq -o=json f.yamlYAML to JSONpython3 -m json.tool f.jsonValidate with no installyamllint -s .Strict YAML lint