toJSON

Bun

Symbol

Headers.toJSON

toJSON(): Record<string, string>

Convert Headers to a plain JavaScript object.

About 10x faster than Object.fromEntries(headers.entries())

Called when you run JSON.stringify(headers)

Does not preserve insertion order. Well-known header names are lowercased. Other header names are left as-is.