Starting points for your own code. Run them in the environment shown below.
Node.js 22+ · ES module (.mjs)
Current inputs apply only to fields used by the example. Selected files are not embedded.
Install dependencies
const raw = "Content-Type: application/json\nCache-Control: no-store";
const headers = [];
for (const line of raw.split(/\r?\n/)) {
if (!line.trim() || /^HTTP\//i.test(line)) continue;
const colon = line.indexOf(":");
if (colon <= 0) throw new Error("Invalid header: " + line);
headers.push([line.slice(0, colon).trim().toLowerCase(), line.slice(colon + 1).trim()]);
}
console.log(headers); // Array preserves duplicate Set-Cookie fields.
Put it to work
Structure response headers while retaining duplicate fields.
Details that matter
Format and meaning
Names precede the colon. Repeated fields are kept as arrays.
Supported scope and limits
Text 1 MB
Split inputs that exceed the limit. If a format or algorithm is unsupported, choose a tool that matches your requirements instead of silently changing the format.