JavaScript JSON Methods

About This Index
This page is the JavaScript JSON Methods index. The global JSON object helps you move data between text and values. Each row below links to a full guide with syntax, examples you can run, and FAQs.
Start with JSON.parse() and JSON.stringify(). Open the raw helpers when you need to embed already-valid JSON text without encoding it twice.
JSON.parse() reads a string. JSON.stringify() writes a string. Objects you already have in memory do not need parsing again.
How to Call a JSON Method
Call the methods on the global JSON object. No import is needed:
const text = '{"name":"Ann","age":20}';
const user = JSON.parse(text);
console.log(user.name); // Ann
const out = JSON.stringify(user, null, 2);
console.log(out);
// Newer (ES2024): embed ready-made JSON text
if (typeof JSON.rawJSON === "function") {
const payload = { id: JSON.rawJSON("42") };
console.log(JSON.stringify(payload)); // {"id":42}
console.log(JSON.isRawJSON(payload.id));
} JavaScript JSON Methods Table
All method guides in this JavaScript tutorial series (4 tutorials), grouped by what they do.
Convert text and values
2 methodsThe two methods you use most often.
| Method | Description | Tutorial |
|---|---|---|
JSON.parse() | Read a JSON string and build a JavaScript value. | Open |
JSON.stringify() | Turn a JavaScript value into a JSON string. | Open |
Raw JSON values
2 methodsNewer helpers (ES2024) for embedding already-valid JSON text.
| Method | Description | Tutorial |
|---|---|---|
JSON.rawJSON() | Wrap valid JSON text so stringify pastes it as-is. | Open |
JSON.isRawJSON() | Return true when a value came from JSON.rawJSON(). | Open |
Frequently Asked Questions
Start with JSON.parse()
Open the guide for reading JSON text: syntax, examples, and FAQs.
14 people found this page helpful
