DEV Community

Cover image for Why I Built http-status-toolkit — A Better Alternative to http-status-codes
Rashedin | FullStack Developer
Rashedin | FullStack Developer

Posted on • Edited on

Why I Built http-status-toolkit — A Better Alternative to http-status-codes

In my backend projects, I got tired of constantly writing raw status code numbers like:

res.status(200)
res.status(404)
Enter fullscreen mode Exit fullscreen mode

It works — but it's not expressive. And honestly, it makes code harder to read and maintain over time. Like many developers, I wanted something cleaner, more intuitive, and easier to understand at a glance.

So I looked into existing solutions.


🚫 First I Tried http-status-codes

http-status-codes is a well-known package. With it, you can write:

import { StatusCodes } from "http-status-codes";
res.status(StatusCodes.OK);
Enter fullscreen mode Exit fullscreen mode

Much better than hardcoded numbers — but it came with a few drawbacks:

  • ❌ No ESM support
  • ❌ No localization
  • ❌ No detailed reason phrases
  • ❌ Separate type definitions (@types/http-status-codes)
  • ❌ No localization or i18n support

It didn’t quite solve my problems. So I kept looking.


😐 Then I Tried http-status

http-status is another popular choice. It does support both CommonJS and ESM out of the box — nice. But it still had some limitations:

  • ❌ No localization or i18n support
  • ❌ Only short, generic messages
  • ❌ No detailed descriptions for each code
  • ❌ Lacks modern TypeScript typings
  • ❌ Not tree-shakable

So again — better than nothing, but not enough.


✅ So I Built http-status-toolkit

I created http-status-toolkit to solve all of the above. It’s modern, lightweight, and built for real-world developer needs.

Here’s what it offers:

  • TypeScript-first with full type safety and autocompletion
  • ESM and CommonJS support
  • Short + detailed human-readable messages
  • Localization support in 10+ languages
  • Tree-shakable and subpath exportable
  • ✅ Built with tsup for clean, modern builds
  • ✅ Extremely lightweight: ~4.1 KB minified / ~2.2 KB gzipped

🧪 Example Usage

import { StatusCodes, getStatusMessage } from "http-status-toolkit";

console.log(StatusCodes.OK); 
// 200

console.log(getStatusMessage(StatusCodes.NOT_FOUND)); 
// "Not Found"

// Detailed message
import DetailedMessages from "http-status-toolkit/messages-detailed";
console.log(getStatusMessage(StatusCodes.NOT_FOUND, { variant: DetailedMessages }));
// "Not Found: The requested resource could not be found but may be available in the future."

// Localized message (Bengali)
import BengaliMessages from 'http-status-toolkit/messages-bn';
console.log(getStatusMessage(StatusCodes.NOT_FOUND, { variant: BengaliMessages }));
// Output: (Not Found message in Bengali)

Enter fullscreen mode Exit fullscreen mode

📊 Feature Comparison

📦 Bundle size is based on Bundlephobia


💡 Why It Matters

http-status-toolkit improves:

  • Readability: No more res.status(403) — use StatusCodes.FORBIDDEN
  • Clarity: Choose between short, detailed, or localized messages
  • Internationalization: Easily display meaningful error responses in your users' languages
  • Developer Experience: Clean API, tree-shakable, and TypeScript-native

🧭 Want to Explore?


Built with ❤️ and TypeScript by Rashedin Islam

If you find it useful, consider giving it a ⭐ on GitHub.

Top comments (10)

Collapse
 
russell_ahmed profile image
Russell Ahmed

But the bengali status message doesn't support well in the terminal, it breaks.

Collapse
 
dev-rashedin profile image
Rashedin | FullStack Developer • Edited

yeah, true, but that's terminal issue. And it looks better on browser an postman.

Collapse
 
russell_ahmed profile image
Russell Ahmed

hmm, nice effort by the way.

Thread Thread
 
dev-rashedin profile image
Rashedin | FullStack Developer

thanks.

Collapse
 
alifar profile image
Ali Farhat

Interesting read brother 🙌

Collapse
 
dev-rashedin profile image
Rashedin | FullStack Developer

Thanks for your valuable comment brother, it means a lot.

Collapse
 
ru_stark_b33bfee90679d6e4 profile image
Ru Stark

I normally use http-status. now I have to try this one, well done brother.

Collapse
 
dev-rashedin profile image
Rashedin | FullStack Developer

Please let me know your feedback. It would help to optimize the package further.

Collapse
 
julker_nine_cc0638b446c0b profile image
Julker Nine

Well, never heard of these types of packages before 😀. I recently installed and used it in one of me latest express projects. Now my code looks a bit cleaner.

Collapse
 
dev-rashedin profile image
Rashedin | FullStack Developer

Thanks for your feedback. Glad it helped.