New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

http-body

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-body

Parse the stream body into text/json/buffer/urlencoded.

latest
Source
npmnpm
Version
1.0.18
Version published
Weekly downloads
68
25.93%
Maintainers
1
Weekly downloads
 
Created
Source

http-body

Last version Coverage Status NPM Status

Parse the stream body into text/json/buffer/urlencoded (437 bytes).

Install

$ npm install http-body --save

Usage

const { buffer, text, json, urlencoded } = require('http-body')

/* into buffer */
await buffer(req)
// => <Buffer 7b 22 70 72 69 63 65 22 3a 20 39 2e 39 39 7d>

/* into text */
await text(req)
// => '{"price": 9.99}'

/* into json */
await json(req)
// => { price: '9.99' }

/* into URLSearchParams */
await urlencoded(req)
// => 'price=9.99'

The max body size allowed by default is 1 MB. That can be customize as second argument:

const { buffer, text, json, urlencoded } = require('http-body')
const bytes = require('bytes')

await buffer(req, { limit: bytes('1mb')})
// => TypeError: body size (1112140) is over the limit (1048576)

API

text(req, options)

Converts request body to string.

urlencoded(req, options)

Parses request body using new URLSearchParams.

json(req, options)

Parses request body using JSON.parse.

buffer(req, options)

Minimal body parsing without any formatting.

Options

limit

Type: number
Default: 1048576

The max body size allowed.

If the request body exceeds it, it throws an error.

License

http-body © Kiko Beats, released under the MIT License.
Authored and maintained by Kiko Beats with help from contributors.

kikobeats.com · GitHub Kiko Beats · X @Kikobeats

Keywords

body

FAQs

Package last updated on 18 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts