toJSON

Bun

Symbol

__internal.BunHeadersOverride.toJSON

toJSON(): Record<string, string> & { set-cookie: 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.