Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including @middy/http-header-normalizer with all npm packages installed. Try it out:

require("@middy/core/package.json"); // @middy/core is a peer dependency. var httpHeaderNormalizer = require("@middy/http-header-normalizer")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@middy/http-header-normalizer v1.1.0

Http header normalizer middleware for the middy framework

Middy http-header-normalizer middleware

Middy logo

HTTP header normalizer middleware for the middy framework, the stylish Node.js middleware engine for AWS Lambda

This middleware normalizes HTTP header names to their canonical format. Very useful if clients are not using the canonical names of header (e.g. content-type as opposed to Content-Type).

API Gateway does not perform any normalization, so the headers are propagated to Lambda exactly as they were sent by the client.

Other middlewares like jsonBodyParser or urlEncodeBodyParser will rely on headers to be in the canonical format, so if you want to support non-normalized headers in your app you have to use this middleware before those ones.

This middleware will copy the original headers in event.rawHeaders.


To install this middleware you can use NPM:

npm install --save @middy/http-header-normalizer


  • normalizeHeaderKey (function) (optional): a function that accepts an header name as a parameter and returns its canonical representation.
  • canonical (bool) (optional): if true, modifies the headers to canonical format, otherwise the headers are normalized to lowercase (default false)

Sample usage

const middy = require('@middy/core')
const httpHeaderNormalizer = require('@middy/http-header-normalizer')

const handler = middy((event, context, cb) => {
  cb(null, {})


Middy documentation and examples

For more documentation and examples, refers to the main Middy monorepo on GitHub or Middy official website.


Everyone is very welcome to contribute to this repository. Feel free to raise issues or to submit Pull Requests.


Licensed under MIT License. Copyright (c) 2017-2018 Luciano Mammino and the Middy team.

FOSSA Status

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free