HTTP Header Parser
Convert raw request or response headers into structured JSON for API, proxy and server debugging.
Back to all tools on ToolForge
JSON Result
About HTTP Header Parser
This HTTP header parser turns raw header text into structured JSON so it is easier to inspect and work with.
Header Parsing Algorithm
// Parse headers to JSON
function parseHeaders(text) {
const headers = {};
text.split('\n').forEach(line => {
const colonIndex = line.indexOf(':');
if (colonIndex > 0) {
const key = line.slice(0, colonIndex).trim();
const value = line.slice(colonIndex + 1).trim();
if (key) headers[key] = value;
}
});
return headers;
}
// Example input:
// Content-Type: application/json
// Authorization: Bearer token123
// Example output:
// { "Content-Type": "application/json", "Authorization": "Bearer token123" }
Common HTTP Headers
| Header | Purpose |
|---|---|
Content-Type |
Media type of body (json, html, etc.) |
Authorization |
Authentication credentials (Bearer, Basic) |
User-Agent |
Client software identification |
Accept |
Expected response media type |
Set-Cookie |
Server-sent cookie data |
Frequently Asked Questions
- What is the HTTP header format?
- HTTP headers follow the format 'Header-Name: value' with one header per line. Header names are case-insensitive but conventionally use Title-Case (e.g., Content-Type, Authorization). Values are trimmed of leading/trailing whitespace. Multiple headers with the same name can be comma-separated.
- How do I parse headers from cURL or browser dev tools?
- Copy the header section from cURL output (-v flag) or browser Network tab (Request Headers/Response Headers). Paste the raw headers into the parser. The tool splits each line by the first colon, extracts the header name and value, and outputs structured JSON.
- What are common HTTP headers?
- Common request headers: Host, User-Agent, Accept, Authorization, Content-Type, Cookie. Common response headers: Content-Type, Content-Length, Set-Cookie, Cache-Control, X-Frame-Options. Security headers include: Strict-Transport-Security, Content-Security-Policy, X-Content-Type-Options.
- Why parse headers to JSON?
- JSON format makes headers easier to: programmatically access specific values, compare header sets, log for debugging, share with team members, include in API documentation, and use in automated testing scripts. JSON is also more readable for complex header analysis.