JSON.stringify takes more optional arguments.

Try:

 JSON.stringify({a:1,b:2,c:{d:1,e:[1,2]}}, null, 4); // Indented 4 spaces
 JSON.stringify({a:1,b:2,c:{d:1,e:[1,2]}}, null, "\t"); // Indented with tab

From:

How can I beautify JSON programmatically?

It should work in modern browsers, and it is included in json2.js if you need a fallback for browsers that don't support the JSON helper functions. For display purposes, put the output in a <pre> tag to get newlines to show.

Answer from Cristian Sanchez on Stack Overflow
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Global_Objects โ€บ JSON โ€บ stringify
JSON.stringify() - JavaScript | MDN
If it is a number, successive levels in the stringification will each be indented by this many space characters. If it is a string, successive levels will be indented by this string. Each level of indentation will never be longer than 10. Number values of space are clamped to 10, and string values are truncated to 10 characters. ... JSON.stringify({}); // '{}' JSON.stringify(true); // 'true' JSON.stringify("foo"); // '"foo"' JSON.stringify([1, "false", false]); // '[1,"false",false]' JSON.stringify([NaN, null, Infinity]); // '[null,null,null]' JSON.stringify({ x: 5 }); // '{"x":5}' JSON.string
๐ŸŒ
W3Schools
w3schools.com โ€บ js โ€บ js_json_stringify.asp
JSON.stringify()
Use the JavaScript function JSON.stringify() to convert it into a string.
๐ŸŒ
JSON Formatter
jsonformatter.org โ€บ json-stringify-online
JSON Stringify Online using JSON.Stringify()
JSON Stringify Online helps convert string value to JSON String using JSON.Stringify().
๐ŸŒ
ServiceNow Community
servicenow.com โ€บ community โ€บ developer-articles โ€บ json-stringify-making-json-look-pretty-and-perfect โ€บ ta-p โ€บ 2534944
JSON.stringify() - Making JSON Look Pretty and Per... - ServiceNow Community
December 9, 2025 - JSON.stringify() is definitely a helpful method for making JSON data more readable and organized. Additionally, it's important to note that JSON is widely used for data interchange between web services and applications, so having well-formatted JSON can also make it easier for different systems ...
๐ŸŒ
Keyboard Maestro
forum.keyboardmaestro.com โ€บ tips & tutorials
TIP: How to Get Readable Format from JSON.stringify() - Tips & Tutorials - Keyboard Maestro Discourse
March 20, 2017 - TIP: How to Get Readable Format from JSON.stringify() I suspect most of you JavaScript and JavaScript for Automation (JXA) scripters are at least somewhat familiar with the powerful JSON functions, like JSON.stringify() - JavaScript | MDN. However, some of you, like me, may not be aware of some options of the JSON.stringify() function to generate a very readable output, and to filter the output.
๐ŸŒ
ReqBin
reqbin.com โ€บ code โ€บ javascript โ€บ ounkkzpp โ€บ javascript-pretty-print-json-example
How do I pretty print JSON in JavaScript?
To make JSON readable, you need to generate a pretty JSON string. JavaScript has a built-in JSON.stringify(obj, replacer, space) method to convert objects to JSON and pretty-print the generated JSON string.
๐ŸŒ
JavaScript.info
javascript.info โ€บ tutorial โ€บ the javascript language โ€บ data types
JSON methods, toJSON
JSON is a data format that has its own independent standard and libraries for most programming languages. JSON supports plain objects, arrays, strings, numbers, booleans, and null. JavaScript provides methods JSON.stringify to serialize into JSON and JSON.parse to read from JSON.
Find elsewhere
๐ŸŒ
DhiWise
dhiwise.com โ€บ post โ€บ javascript-essentials-detailed-exploration-of-json-stringify
Exploring JSON Stringify: An In-Depth Exploration
September 29, 2023 - JSON Stringify is a method in JavaScript that converts JavaScript objects into JSON strings. JSON stands for JavaScript Object Notation, a lightweight data-interchange format that is easy for humans to read and write and easy for machines to ...
๐ŸŒ
The Code Barbarian
thecodebarbarian.com โ€บ pretty-json-stringify-output.html
Pretty `JSON.stringify()` Output in JavaScript
This lets you format the JSON: const app = express(); app.use(express.text({ type: '*/*' })); app.post('*', (req, res) => { console.log(req.body); res.end(req.body); }); await app.listen(3000); // Make a test request const axios = require('axios'); const obj = { name: 'Jean-Luc Picard', rank: 'Captain', ship: 'Enterprise D' }; const res = await axios.post('http://localhost:3000', obj, { transformRequest: data => JSON.stringify(data, null, 2), // Send pretty formatted JSON transformResponse: body => body }); // { // "name": "Jean-Luc Picard", // "rank": "Captain", // "ship": "Enterprise D" // } console.log(res.data);
๐ŸŒ
W3Schools
w3schools.com โ€บ jsref โ€บ jsref_stringify.asp
JavaScript JSON stringify() Method
/*replace the value of "city" to upper case:*/ var obj = { "name":"John", "age":"39", "city":"New York"}; var text = JSON.stringify(obj, function (key, value) { if (key == "city") { return value.toUpperCase(); } else { return value; } }); Try it Yourself ยป
๐ŸŒ
4D
developer.4d.com โ€บ 4d language โ€บ commands by theme โ€บ json โ€บ json stringify
JSON Stringify | 4D Docs
This command performs the opposite action of the JSON Parse command. Pass the data to be serialized in value. It can be expressed in scalar form (string, number, date or time) or by means of a 4D object or collection. Note: 4D dates will be converted either in "yyyy-mm-dd" or "YYYY-MM-DDTh...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ how-to-pretty-print-json-string-in-javascript
How to Pretty Print JSON String in JavaScript? - GeeksforGeeks
July 12, 2025 - The JSON object to stringify. A replacer function (optional). The number of spaces for indentation (optional). ... By providing an indentation value, you can control the amount of spacing for nested elements. ... const data = { name: "Anjali", profession: "Developer", skills: ["JavaScript", "Python"] }; const formatted = JSON.stringify(data, null, 4); console.log(formatted);
๐ŸŒ
Online Tools
onlinetools.com โ€บ json โ€บ stringify-json
Stringify JSON โ€“ Online JSON Tools
For example, it can convert a JavaScript expression, a JSON object, a string with special characters, and a larger text with newlines into a compactly stringified JSON string. It works in the browser and uses the native JSON.stringify() function to get the job done.
๐ŸŒ
GitHub
github.com โ€บ DJj123dj โ€บ formatted-json-stringify
GitHub - DJj123dj/formatted-json-stringify: An advanced & customisable version of the javascript JSON.stringify() function!
It's just a wrapper around the default JSON.stringify()! const input = { property1:"this is the first property", property2:"this is the second property", property3:123, subObject:{ sub_property_1:true, sub_property_2:false, sub_array:["abcd","efg","hijk","lmnop","qrst","uvw","xyz","and thats the alphabet!"] } } const formatter = new fjs.ObjectFormatter(null,true,[ new fjs.PropertyFormatter("property1"), new fjs.PropertyFormatter("property2"), new fjs.PropertyFormatter("property3"), new fjs.TextFormatter(), //we don't know the contents of this object //but we still want to render it multiline/inline new fjs.DefaultFormatter("subObject",true)
Author ย  DJj123dj
๐ŸŒ
Testmu
testmu.ai โ€บ home โ€บ free tools โ€บ json stringify online
JSON Stringify Online | Free online tool to Stringify JSON
The text stringifier() function ... storage, and communication. JSON.stringify() is a powerful method in JavaScript used to convert a JavaScript object into a JSON string....
๐ŸŒ
DEV Community
dev.to โ€บ david_j_eddy โ€บ til-jsonstringify-can-do-formatted-output-1f44
TIL: JSON.stringify() can do formatted output. - DEV Community
December 18, 2017 - var obj = {name: "bob", lastname: "jones", age: 24, favouriteFood: "food", favouriteColour: "blue?", loves: "biscuits" }; JSON.stringify(obj, null, "two spaces"); "{ two spaces"name": "bob", two spaces"lastname": "jones", two spaces"age": 24, two spaces"favouriteFood": "food", two spaces"favouriteColour": "blue?", two spaces"loves": "biscuits" }"
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ javascript-json-stringify-method
JavaScript JSON stringify() Method - GeeksforGeeks
July 11, 2025 - The JSON.stringify() method in JavaScript is used to convert JavaScript objects into a JSON string. This method takes a JavaScript object as input and returns a JSON-formatted string representing that object.
๐ŸŒ
Built In
builtin.com โ€บ software-engineering-perspectives โ€บ json-stringify
How to Use JSON.stringify() and JSON.parse() in JavaScript | Built In
In JavaScript, JSON.stringify() converts a JavaScript object into a JSON-formatted string, allowing it to be stored or transmitted easily.