JSON.stringify turns a JavaScript object into JSON text and stores that JSON text in a string, eg:

var my_object = { key_1: "some text", key_2: true, key_3: 5 };

var object_as_string = JSON.stringify(my_object);  
// "{"key_1":"some text","key_2":true,"key_3":5}"  

typeof(object_as_string);  
// "string"  

JSON.parse turns a string of JSON text into a JavaScript object, eg:

var object_as_string_as_object = JSON.parse(object_as_string);  
// {key_1: "some text", key_2: true, key_3: 5} 

typeof(object_as_string_as_object);  
// "object" 
Answer from Quentin on Stack Overflow
🌐
Squash
squash.io › how-to-use-json-parse-and-stringify-in-javascript
How to Use JSON Parse and Stringify in JavaScript
September 9, 2023 - However, similar to JSON.parse(), the performance impact of JSON stringification is generally minimal.
🌐
W3Schools
w3schools.com › js › js_json_syntax.asp
JSON Syntax
JSON Intro JSON Syntax JSON vs XML JSON Data Types JSON Parse JSON Stringify JSON Objects JSON Arrays JSON Server JSON PHP JSON HTML JSON JSONP JS jQuery
Discussions

Microsoft Foundry HTTP 500 error
Hi, I have been building a workflow using the new Microsoft Foundry, and once I've tested it in the Portal UI, using the Preview feature, I have published my workflow, giving me a endpoint following: … More on learn.microsoft.com
🌐 learn.microsoft.com
1
0
1 week ago
[Performance] Deep Copy vs JSON Stringify / JSON Parse
I've noticed a lot of places in the code that makes copy of an object by using JSON Stringify + JSON Parse. I have found a jsPerf that compares few technics for deep object cloning and this one is ... More on github.com
🌐 github.com
3
February 28, 2018
Trying to learn fetch(), JSON.stringify() confusion
You use express.json middleware which tried to parse the body as JSON. hello is not valid JSON. More on reddit.com
🌐 r/learnjavascript
14
1
December 8, 2020
Json stringify
Hello, related to the last question I have a doubt using JSON.stringify I have a database, with multiple cells, and under each cell, values. Cells are: id, name, duration, date, and relationid In this database I have … More on sitepoint.com
🌐 sitepoint.com
0
July 6, 2018
🌐
Medium
enricopiovesan.com › json-stringify-just-got-twice-as-fast-what-developers-need-to-know-649e6ae4d127
JSON.stringify Just Got Twice as Fast: What Developers Need to Know | by Enrico Piovesan | Medium
August 16, 2025 - This time, the detail that caught my attention was JSON.stringify. At first glance, it might sound like the last thing worth spending a Saturday on. After all, it is just a built-in function. Everyone uses it, but no one really thinks about it. You pass an object, and it returns a string; then you move on.
🌐
JSONLint
jsonlint.com
JSONLint - The JSON Validator
JSONLint is the free online validator, json formatter, and json beautifier tool for JSON, a lightweight data-interchange format.
🌐
Microsoft Learn
learn.microsoft.com › en-nz › answers › questions › 5791271 › microsoft-foundry-http-500-error
Microsoft Foundry HTTP 500 error - Microsoft Q&A
1 week ago - async function runFoundryWorkflow({ invokeUrl, input }) { const token = await getAiAzureBearer(); const bodyObj = { input }; const bodyStr = JSON.stringify(bodyObj); const res = await fetch(invokeUrl, { method: "POST", headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json", "Accept": "application/json" }, body: bodyStr, }); const text = await res.text(); if (!res.ok) { let reqId = null; try { reqId = JSON.parse(text)?.error?.additionalInfo?.request_id; } catch (_) { } console.error("[FOUNDRY WF ERROR]", { status: res.status, request_id: reqId, payload_bytes: Buffer.byteLength(bodyStr, "utf8"), payload_head: bodyStr.slice(0, 2000), response_head: text.slice(0, 2000), headers: Object.fromEntries(res.headers.entries()), }); throw new Error(`Workflow HTTP ${res.status}: ${text}`); } try { return JSON.parse(text); } catch { return text; } }
🌐
GitHub
github.com › raml-org › raml-js-parser-2 › issues › 814
[Performance] Deep Copy vs JSON Stringify / JSON Parse · Issue #814 · raml-org/raml-js-parser-2
February 28, 2018 - I've noticed a lot of places in the code that makes copy of an object by using JSON Stringify + JSON Parse. I have found a jsPerf that compares few technics for deep object cloning and this one is ...
Published   Feb 28, 2018
🌐
Reddit
reddit.com › r/learnjavascript › trying to learn fetch(), json.stringify() confusion
r/learnjavascript on Reddit: Trying to learn fetch(), JSON.stringify() confusion
December 8, 2020 -

I am in the process of learning about client and server side and sending things back and forth.

I am running an express server and trying to get a log in my console on the server side.

This is my server.js:

//Imports
const express = require('express');

//Setup and configure app
const app = express();
const port = 5000;

//parse JSON files
app.use(express.json());

//serve static files
app.use(express.static('public'));

//Initialize app
app.listen(port, () => console.log(`Server listening on port ${port}!`));

app.post('/api', (request, response) => {
  console.log(request.body);
});

Why does this work and give an output on the console:

const data = {
    name: 'john',
    age: 28
};

const options = {
  method: 'post',
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify(data)
};

fetch('/api', options);

And when I change the variable data to a simple string it does not work:

const data = "hello";

And I will get this parsing error:

SyntaxError: Unexpected token " in JSON at position 0

Same behavior for integers.

Any help is greatly appreciated!

Find elsewhere
🌐
SitePoint
sitepoint.com › javascript
Json stringify
July 6, 2018 - Hello, related to the last question I have a doubt using JSON.stringify I have a database, with multiple cells, and under each cell, values. Cells are: id, name, duration, date, and relationid In this database I have 3 rows: I have this code: var result = {} properties.data.forEach(addToResult); //Get data from database using properties.data instance.data.datavarb = JSON.stringify(result); //Send data after converted to JSON function addToResult(pair,isjson){ //operations ...
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › what-is-difference-between-json-parse-and-json-stringify-methods-in-javascript
What is difference between JSON.parse() and ...
July 23, 2025 - JSON.parse() converts JSON strings to JavaScript objects, while JSON.stringify() converts JavaScript objects to JSON strings. JavaScript utilizes JSON for data interchange between servers and web pages.
🌐
freeCodeCamp
freecodecamp.org › news › json-stringify-method-explained
JSON Object Examples: Stringify and Parse Methods Explained
February 16, 2020 - //JSON-unsafe values passed as properties on a object var obj = { x: undefined, y: Object, z: Symbol('') }; //JSON.stringify(obj); logs '{}' obj.toJSON = function(){ return { x:"undefined", y: "Function", z:"Symbol" } } JSON.stringify(obj); //"{"x":"undefined","y":"Function","z":"Symbol"}" //JSON-unsafe object with circular reference on it var o = { }, a = { b: 42, c: o, d: function(){} }; // create a circular reference inside `a` o.e = a; // would throw an error on the circular reference // JSON.stringify( a ); // define a custom JSON value serialization a.toJSON = function() { // only include the `b` property for serialization return { b: this.b }; }; JSON.stringify( a ); // "{"b":42}" The replacer, as mentioned earlier, is a filter which indicates which properties are to be included in the JSON string.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › JSON › stringify
JSON.stringify() - JavaScript | MDN
The JSON.stringify() static method converts a JavaScript value to a JSON string, optionally replacing values if a replacer function is specified or optionally including only the specified properties if a replacer array is specified.
🌐
Medium
medium.com › @ronaldssebalamu › json-parse-vs-json-stringify-ad2d3218bc44
JSON.parse() vs JSON.stringify(). Today we are yet to delve into one of… | by Ronald Ssebalamu | Medium
September 13, 2023 - Conclusion JSON.parse() is used to convert JSON data into a JavaScript object , to make it accessible and modifiable with in the JavaScript code. JSON.stringify() is used to convert a JavaScript object into a JSON formatted string, that is usually ...
🌐
Team Treehouse
teamtreehouse.com › community › what-is-the-difference-between-json-and-jsonparse
what is the difference between json() and json.parse()? (Example) | Treehouse Community
April 6, 2021 - Keep in mind JSON.parse() is used to turn AJAX response JSON data (sent as a string) into a JSON object in the response handler code, so the values can be extracted efficiently/expediently from the JOSN (via the object attributes or key/value pairs). ... Also, be aware of JSON.stringify which does the opposite.
🌐
V8
v8.dev › blog › json-stringify
How we made JSON.stringify more than twice as fast · V8
At the end, the final result is constructed by simply concatenating the output from the initial one-byte stringifier with the output from the two-byte one. This strategy ensures we stay on a highly-optimized path for the common case, while the transition to handling two-byte characters is lightweight and efficient. Any string in JavaScript can contain characters that require escaping when serializing to JSON (e.g.
🌐
Built In
builtin.com › software-engineering-perspectives › json-stringify
How to Use JSON.stringify() and JSON.parse() in JavaScript | Built In
Summary: JSON.stringify() converts a JavaScript object into a JSON string, and JSON.parse() reverses the process. These methods are often used together to handle JSON data, but they don’t support certain types like undefined, Infinity, NaN, ...
🌐
Attacomsian
attacomsian.com › blog › json-parse-stringify
Understanding JSON.parse() and JSON.stringify()
October 3, 2022 - The JSON.parse() method takes a string as input and transforms it into an object. Similarly, JSON.stringify() takes a JSON object and converts it into a string.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › JSON › parse
JSON.parse() - JavaScript | MDN
JSON.parse( '{"p": 5}', (key, value) => typeof value === "number" ? value * 2 // return value * 2 for numbers : value, // return everything else unchanged ); // { p: 10 } JSON.parse('{"1": 1, "2": 2, "3": {"4": 4, "5": {"6": 6}}}', (key, value) => { console.log(key); return value; }); // 1 // 2 // 4 // 6 // 5 // 3 // "" In order for a value to properly round-trip (that is, it gets deserialized to the same original object), the serialization process must preserve the type information. For example, you can use the replacer parameter of JSON.stringify() for this purpose:
🌐
Studytonight
studytonight.com › forum › difference-between-jsonstringify-and-jsonparse
Difference between JSON.stringify and JSON.parse - Studytonight
June 1, 2021 - JSON.stringify({}); // '{}' ... Boolean(false)]); // '[1,"false",false]' JSON.parse() The JSON.parse() method parses a string as JSON, optionally transforming the value produced....