New: HCEL — chain prompts, RAG, and agents in native TypeScript Learn more →
HazelJS LogoHazelJS

Comparison

HazelJS vs Express

Express maximizes freedom with middleware. HazelJS maximizes structure for TypeScript AI backends — controllers, DI, and AI packages included.

Updated August 4, 2026

HazelJS vs Express

TL;DR

  • Express is the minimal, unopinionated Node HTTP toolkit — huge ecosystem, maximum freedom.
  • HazelJS adds Nest-style structure plus native AI (agents, RAG, HCEL) in one TypeScript framework.
  • Keep Express for tiny APIs, prototypes, or when you already own all the architecture pieces.
  • Choose HazelJS when you want controllers, DI, validation, and AI without assembling ten libraries.

Who this is for

Developers who:

  • Prototype on Express and need a path to structured AI backends
  • Compare Express + openai SDK vs a full framework
  • Want TypeScript-first modules without going full Nest

Stay on Express if the service is a thin proxy, a webhook receiver, or you deliberately avoid frameworks.

Side-by-side

AspectExpressHazelJS
API styleCallback / middlewareDecorators, controllers
DINone (manual)Full DI with scopes
ValidationManual (Joi, Zod, …)Built-in validation patterns
Type safetyLimited unless you add layersTypeScript-first end to end
TestingManual setupTesting utilities + agent tests
AIDIY (SDK + your glue)Native AI, agent, RAG modules
MicroservicesDIYGateway, discovery, resilience
Learning curveVery lowModerate (decorators/modules)

Code: middleware pile vs module

Express + manual AI glue:

import express from 'express';
import OpenAI from 'openai';

const app = express();
app.use(express.json());
const openai = new OpenAI();

app.post('/chat', async (req, res) => {
  // auth, rate limit, retrieval, agent loop — all DIY
  const completion = await openai.chat.completions.create({
    model: 'gpt-4o',
    messages: [{ role: 'user', content: req.body.message }],
  });
  res.json(completion);
});

HazelJS structured endpoint:

import { Controller, Post, Body, HazelModule } from '@hazeljs/core';
import { AITask } from '@hazeljs/ai';

@Controller({ path: '/chat' })
class ChatController {
  @AITask({ provider: 'openai', model: 'gpt-4o' })
  @Post()
  async chat(@Body() body: { message: string }) {
    return body.message;
  }
}

@HazelModule({ controllers: [ChatController] })
export class AppModule {}

Decision guide

SituationPrefer
Webhook / 50-line APIExpress
Growing AI product backendHazelJS
Team loves Nest patterns but needs AIHazelJS (or Nest — see vs NestJS)
Max raw control, zero opinionsExpress

When Express is better

  • Extreme minimalism or edge cases where a framework fights you
  • Existing Express codebase with no AI roadmap
  • Teaching HTTP fundamentals

Migration

Map routes → controllers, middleware → guards/middleware packages, and add @hazeljs/ai / agent when ready.

Migrate from Express to HazelJS

Related

Next steps

  1. Installation
  2. Controllers guide
  3. Introduction
  4. GitHub

FAQ

Is HazelJS heavier than Express?
Yes — it is a framework with modules and DI. That overhead buys structure, TypeScript patterns, and native AI packages you would otherwise assemble yourself.
Can I migrate Express routes gradually?
Yes. Start a HazelJS service for new AI surfaces or rewrite route groups as controllers. See the Express migration guide.
Does HazelJS replace middleware?
HazelJS supports middleware plus guards, pipes, and interceptors. Common cross-cutting concerns also exist as packages (auth, rate limits, etc.).
When should I keep Express?
Tiny APIs, webhooks, teaching demos, or when you explicitly want zero framework opinions and no AI roadmap.

Docs & next steps

Related comparisons

  • HazelJS vs NestJS

    NestJS is excellent for structured APIs. HazelJS keeps a familiar module/DI model and adds native AI, agents, RAG, and Agent OS in the same stack.

  • HazelJS vs Vercel AI SDK

    Vercel AI SDK optimizes streaming UX on Vercel. HazelJS is the backend framework for agents, RAG, and enterprise TypeScript APIs — they can complement each other.

  • HazelJS vs LangChain

    LangChain composes LLM pipelines. HazelJS ships those capabilities inside a production TypeScript backend — controllers, agents, RAG, and ops together.

← All comparisons