How to convert json object to query string in node js

Updated at 01-Oct-2021, By samar

How to convert json object to query string in node js

With this article, we will examine several different instances of how to solve the "How to convert json object to query string in node js".

You can convert the json object to query string in node js using stringify method. You have to just pass the object value to stringify method on querystring module it will convert the json object to query string node js.
  • Convert json object to query string in node js

    querystring = require('querystring');  
    const qs1=querystring.stringify({name:'samar',company:'w3codegenerator.com'});  
    console.log(qs1); 
    

    Output:

    name=samar&company=w3codegenerator.com

    This code snippet will help you to convert the json object ({name:'samar',company:'w3codegenerator.com'}) to query string format (name=samar&company=w3codegenerator.com).

Back to code snippet queries related nodejs