JSON — Complete Guide
JSON — Complete Guide: free step-by-step lesson with examples, common mistakes, and interview tips — part of JavaScript Tutorial on Toolliyo Academy.
On this page
JavaScript Tutorial · Lesson 47 of 100
JSON
Basics ✓ → Objects & data ✓ → Async & DOM → Advanced → Tools → Projects
Intermediate · 3 — Async & DOM · ~6 min · JS Async JavaScript
What is this?
JSON is text format for data — looks like JavaScript objects but uses double quotes for keys. APIs send and receive JSON.
Why should you care?
fetch returns JSON. localStorage often stores JSON strings.
See it live — copy this example
Paste into an HTML file or the browser console (F12). Use Run below when the live editor is available.
const user = { name: "Kiran", score: 88 };
const json = JSON.stringify(user);
console.log(json);
const copy = JSON.parse(json);
console.log(copy.name);
Run Example »
Edit the code below and click Run to see the result in Toolliyo’s live editor.
What happened?
- JSON.stringify turns an object into a string.
- JSON.parse turns a string back into an object.
- Round-trip preserves data.
Practice next
- Stringify an object and log the string.
- Parse back and read a property.
- Parse invalid JSON and read SyntaxError.
- Stringify an array of three product objects.
- Use JSON.stringify with a replacer to hide password fields.
Remember
JSON.stringify → string JSON.parse → object Standard for web APIs
ScriptVerse settings sync
User theme preference saves as JSON string in localStorage and parses on app boot.
Outcome: JSON is the lingua franca between browser JavaScript and backend services.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!