← JavaScript

JSON – stringify and parse

Converts a JavaScript value into a JSON-formatted string.

Understanding JSON – stringify and parse in JavaScript

What it does: This is exactly what the stringify() method does. stringify() turns an object or array into a JSON-formatted string. JavaScript requires all capitals: JSON.stringify(). JavaScript is case-sensitive, so 'stringify' must be lowercase. Both objects and arrays can be converted into JSON strings. The text must be valid JSON, or parse() will throw an error. JavaScript's built-in object is JSON, not json. The method name is parse(), not Parse().

Common mistakes: 'JSON' must be capitalized - it's not 'json'. 'stringify' must be lowercase - a capital S causes an error.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 41–52) and word search (Modules 21–52).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Does JSON.stringify() convert a JS value into a JSON string?
YesNo
Matches
let j = json.stringify(obj);
↓
Wrong - 'JSON' must be capitalized
Applying
Meanings
Term
JSON.stringify()
Meaning
Converts a JavaScript value into a JSON-formatted string.
Practice
let person = {name: "Sam", age: 12};
Testing
Gaps
let json = JSON.(person);
Check Answer
Spots
1let j = json.parse(s);
2let s = '{"a":1}';

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Viperfish' badge — Deep Debugger, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Does JSON.stringify() convert a JS value into a JSON string?
A. No
B. Yes ✓
stringify() turns an object or array into a JSON-formatted string.
2. Does JSON.parse() convert a JSON string into a JS value?
A. No
B. Yes ✓
parse() turns a JSON string back into a usable object or value.
3. Is 'json' with a lowercase j valid for JSON.stringify()?
A. No ✓
B. Yes
JavaScript requires all capitals: JSON.stringify().
4. Must 'stringify' be written in lowercase?
A. Yes ✓
B. No
JavaScript is case-sensitive, so 'stringify' must be lowercase.
5. Must 'parse' be written in lowercase?
A. Yes ✓
B. No
JavaScript is case-sensitive, so 'parse' must be lowercase.

Match the Pairs

JSON.stringify(person) → Converts the person object into a JSON string
JSON.parse(json) → Converts a JSON string back into a JS value
Converts a JS value into a JSON-formatted string → JSON.stringify(data)
Converts a JSON string into a usable JS value → JSON.parse(text)
let j = json.stringify(obj); → Wrong - 'JSON' must be capitalized
let o = JSON.Parse(text); → Wrong - 'parse' must be lowercase

Key Term

JSON.stringify()
Converts a JavaScript value into a JSON-formatted string.

Fill in the Blanks

1. let json = JSON.stringify(person);
Hint: Type the method that converts a value into a JSON string.
2. let obj = JSON.parse(json);
Hint: Type the method that converts a JSON string back into a value.
3. let text = JSON.stringify(data);
Hint: Type the method that converts a value into a JSON string.
4. let result = JSON.parse(text);
Hint: Type the method that converts a JSON string back into a value.
5. let data2 = JSON.stringify({a: 1});
Hint: Type the method that converts a value into a JSON string.

Spot the Error

Question 1
A let j = json.parse(s);
B let s = '{"a":1}';
C console.log(j);
Line A — 'JSON' must be capitalized - it's not 'json'.
Question 2
A let t = {b: 2};
B let j = JSON.Stringify(t);
C console.log(j);
Line B — 'stringify' must be lowercase - a capital S causes an error.
Question 3
A let u = {c: 3};
B let j2 = JSON.stringify(u);
C let k = JSON.Parse(j2);
Line C — 'parse' must be lowercase - a capital P causes an error.
Question 4
A let m = Json.stringify(x);
B let x = {d: 4};
C console.log(m);
Line A — 'JSON' must be all uppercase, not 'Json'.
Question 5
A let y = {e: 5};
B let n = JSON.stringfy(y);
C console.log(n);
Line B — 'stringify' is misspelled as 'stringfy'.

Student with a class code? Join your class →