Skip to content

Console log JSON stringify | JavaScript example

  • by

Console log JSON stringify means converting a JavaScript object or value to a JSON string. The console log will show the string output.

JavaScript Console log JSON stringify

Simple example code.

<!DOCTYPE html>

   const sendquery = {
    "async": true,
    "crossDomain": true,
    "url": "",
    "method": "POST",
    "headers": {
      "Authorization": "Bearer " + "tkid",
      "Accept": "application/json",
      "Content-Type": "application/json",
    "processData": false,
    "data": "query"




Console log JSON stringify

console.log inconsistent with JSON.stringify

Use console.dir(obj) instead? Or use console.log(obj) and then click on the output / expand it.

   var obj = {};
   obj.players = {};
   obj.players[0] = {color: "green"};
   obj.players[1] = {color: "blue"}; = "xyz";

I always (Firefox, Chrome, Opera) get this as output:


Do comment if you have any doubts or suggestions on this JS JSON log topic.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version


Leave a Reply

Your email address will not be published. Required fields are marked *