Awesome Open Source
Awesome Open Source

Vulnerabilities Version Coverage Github actions Downloads

Tiniest body parser in the universe. Built for modern Node.js.

Check out deno-libs/parsec for Deno port.


  • ⏩ built with async / await
  • 🛠 JSON / raw / urlencoded data support
  • 📦 tiny package size (728B)
  • 🔥 no dependencies
  • tinyhttp and Express support


# pnpm
pnpm i milliparsec

# yarn
yarn add milliparsec

# npm
npm i milliparsec


Basic example

Use a middleware inside a server:

import { createServer } from 'http'
import { json } from 'milliparsec'

const server = createServer(async (req: ReqWithBody, res) => {
  await json()(req, res, (err) => void err && console.log(err))

  res.setHeader('Content-Type', 'application/json')


Web frameworks integration


import { App } from '@tinyhttp/app'
import { urlencoded } from 'milliparsec'

new App()
  .post('/', (req, res) => void res.send(req.body))
  .listen(3000, () => console.log(`Started on http://localhost:3000`))


raw(req, res, cb)

Minimal body parsing without any formatting.

text(req, res, cb)

Converts request body to string.

urlencoded(req, res, cb)

Parses request body using querystring.parse.

json(req, res, cb)

Parses request body using JSON.parse.

custom(fn)(req, res, cb)

Custom function for parsec.

// curl -d "this text must be uppercased" localhost
await custom(
  (d) => d.toUpperCase(),
  (err) => {}
res.end(req.body) // "THIS TEXT MUST BE UPPERCASED"

What is "parsec"?

The parsec is a unit of length used to measure large distances to astronomical objects outside the Solar System.

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Javascript (1,512,666
Typescript (252,294
Nodejs (53,878
Node (12,547
Express (11,230
Http (5,582
Es6 (5,302
Middleware (2,502
Es6 Javascript (622
Body Parser (150
Related Projects