
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
http-build-query
Advanced tools
Generate URL-encoded query string from the object (php's http_build_query() in JavaScript)
Generate URL-encoded query string from the object (PHP's http_build_query() in JavaScript). Compatible with Node.js ≥6 and modern browsers.
http_build_query() function behavior in JavaScripttrue → "1", false → "0"), numbers, strings, null, and undefinednpm install http-build-query
Or using yarn:
yarn add http-build-query
For browser usage, include via CDN:
<script src="https://unpkg.com/http-build-query"></script>
httpBuildQuery(queryData, numericPrefix, argSeparator, tempKey)queryData (Object): The data to convert to query stringnumericPrefix (String|null): Prefix for numeric keys (default: null)argSeparator (String): Separator between arguments (default: "&")tempKey (String|null): Temporary key for nested objects (used internally for recursion)var httpBuildQuery = require("http-build-query");
var data = {
name: "John Doe",
age: 30,
active: true,
};
var query = httpBuildQuery(data);
// Result: "name=John+Doe&age=30&active=1"
var data = {
0: "value1",
1: "value2",
key: "value3",
};
var query = httpBuildQuery(data, "prefix_");
// Result: "prefix_0=value1&prefix_1=value2&key=value3"
var data = { a: 1, b: 2, c: 3 };
var query = httpBuildQuery(data, null, ";");
// Result: "a=1;b=2;c=3"
var query2 = httpBuildQuery(data, null, "&");
// Result: "a=1&b=2&c=3"
var data = {
user: {
name: "Bob Smith",
age: 47,
sex: "M",
dob: "5/12/1956",
},
pastimes: ["golf", "opera", "poker", "rap"],
children: {
bobby: { age: 12, sex: "M" },
sally: { age: 8, sex: "F" },
},
"+0": "CEO",
};
var query = httpBuildQuery(data, "flags_");
// Result matches PHP's http_build_query() output
<script src="https://unpkg.com/http-build-query"></script>
<script>
var data = { q: "search term", page: 1 };
var query = httpBuildQuery(data);
console.log(query); // "q=search+term&page=1"
</script>
Version 0.8.0 maintains full backward compatibility with previous versions. The only changes are internal improvements:
"use strict" directiveMIT © Vlad Zadvorny
FAQs
Generate URL-encoded query string from the object (php's http_build_query() in JavaScript)
We found that http-build-query demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.