[{"data":1,"prerenderedAt":20},["ShallowReactive",2],{"$fx8g1xzeEGQJNfriVuhKqllaave2BZhFtzGg9ItS1nP0":3},{"slug":4,"title":5,"description":6,"date":7,"tags":8,"draft":12,"readingMinutes":13,"html":14,"related":15},"fastify-vs-express","Fastify vs Express: The Difference Isn't the Benchmark","Fastify vs Express in November 2026: Fastify 5.12 vs Express 5.3, schemas, plugins, logging and the migration path. Which to pick for a new Node API.","2026-11-27",[9,10,11],"fastify","express","nodejs",false,4,"\u003Cp>Every Fastify vs Express comparison opens with a requests-per-second chart, and Fastify wins it. Fine. For almost every API I&#39;d be asked to build, that chart doesn&#39;t matter, because the database query behind the route takes 20 ms and the framework&#39;s overhead is a rounding error next to it. The real differences are about structure: how each one wants you to validate input, shape output, split code and log. That&#39;s what I&#39;d choose on.\u003C/p>\n\u003Cp>Versions on npm, checked November 27, 2026: \u003Cstrong>Fastify 5.12.8\u003C/strong> (published November 2) and \u003Cstrong>Express 5.3.0\u003C/strong> (October 9). Last week&#39;s downloads: Express about 207 million, Fastify about 23.5 million. Express is in my stack and has been for years, so read the rest with that bias in mind.\u003C/p>\n\u003Ch2>The one-line answer\u003C/h2>\n\u003Cp>New API with a team, a schema-first habit and a long life ahead: Fastify. An existing Express app, or a small service where half the work is gluing middleware together: Express 5, and don&#39;t move it. I&#39;ve written about \u003Ca href=\"/blog/hono-vs-express\">Hono vs Express\u003C/a> for the case where the code might run on Workers or Bun; this post is the Node-server case.\u003C/p>\n\u003Ch2>Schemas are the actual feature\u003C/h2>\n\u003Cp>In Express, validation is something you add. You pick zod or joi or express-validator, write a middleware, and remember to put it on each route. Responses go out as whatever object you passed to \u003Ccode>res.json()\u003C/code>, extra fields included.\u003C/p>\n\u003Cp>Fastify puts a JSON Schema on the route itself, for the body, query, params, headers and each response status:\u003C/p>\n\u003Cpre>\u003Ccode class=\"language-js\">fastify.post(&#39;/invoices&#39;, {\n  schema: {\n    body: {\n      type: &#39;object&#39;,\n      required: [&#39;customerId&#39;, &#39;amount&#39;],\n      properties: {\n        customerId: { type: &#39;string&#39; },\n        amount: { type: &#39;integer&#39;, minimum: 1 }\n      }\n    },\n    response: {\n      201: {\n        type: &#39;object&#39;,\n        properties: { id: { type: &#39;string&#39; }, status: { type: &#39;string&#39; } }\n      }\n    }\n  }\n}, async (req, reply) =&gt; {\n  const invoice = await createInvoice(req.body)\n  return reply.code(201).send(invoice)\n})\n\u003C/code>\u003C/pre>\n\u003Cp>Bad input gets a 400 before your handler runs (Ajv, through \u003Ccode>@fastify/ajv-compiler\u003C/code>). The response schema does something people underrate: Fastify serializes with \u003Ccode>fast-json-stringify\u003C/code>, and \u003Cstrong>properties not in the schema are dropped\u003C/strong>. If \u003Ccode>createInvoice\u003C/code> returns the row with an internal \u003Ccode>stripe_customer_id\u003C/code> on it, the client never sees it. In Express that field goes out unless someone remembered to strip it.\u003C/p>\n\u003Cimg src=\"/blog/fastify-vs-express/response-schema-filter.webp\" alt=\"The same database row sent by Express with internal fields, and by Fastify with only the fields in the response schema\" width=\"1600\" height=\"580\" loading=\"lazy\">\u003Cp>That&#39;s the security argument for Fastify, and it&#39;s a better one than speed. It cuts both ways, though. Forget to add a new field to the response schema and it silently vanishes from the API, and somebody on the frontend spends an afternoon wondering why \u003Ccode>dueDate\u003C/code> is undefined. If you write TypeScript, a type provider (TypeBox or zod) keeps the schema and the types in one place so that mostly stops happening.\u003C/p>\n\u003Ch2>Plugins instead of a flat middleware list\u003C/h2>\n\u003Cp>Express has one middleware stack and the order you call \u003Ccode>app.use()\u003C/code> is the order things run. Simple, and it stays simple until the app has 40 routes and an auth middleware that some routes must skip.\u003C/p>\n\u003Cp>Fastify&#39;s \u003Ccode>register()\u003C/code> gives each plugin its own scope. Decorators and hooks registered inside a plugin apply to the routes in that plugin, not to the whole app, unless you wrap it with \u003Ccode>fastify-plugin\u003C/code> to share it upward. You can put the admin routes, their auth hook and their rate limit in one plugin and know nothing leaks into the public routes. It&#39;s more to learn. The first time a hook &quot;doesn&#39;t run&quot; it&#39;s because of encapsulation, every time.\u003C/p>\n\u003Ch2>Logging is already there\u003C/h2>\n\u003Cp>Fastify ships with pino. Turn on \u003Ccode>logger: true\u003C/code> and every request gets a request id and a JSON log line with the response time. In Express you add morgan or pino-http yourself. Not hard, just one more decision, and plenty of Express services run in production with no request ids, which makes reading logs during an incident miserable.\u003C/p>\n\u003Cp>\u003Ccode>fastify.inject()\u003C/code> (from \u003Ccode>light-my-request\u003C/code>) also deserves a mention: you can call a route in a test without opening a port. Express tests usually pull in supertest for the same thing.\u003C/p>\n\u003Ch2>What Express still does better\u003C/h2>\n\u003Cp>The ecosystem. Twenty years of middleware, every tutorial, every Stack Overflow answer, every auth library&#39;s example. Passport, multer, express-session: they assume Express. Fastify has its own versions (\u003Ccode>@fastify/multipart\u003C/code>, \u003Ccode>@fastify/session\u003C/code> and so on), and they&#39;re good, but when you hit an odd integration the Express answer usually exists already.\u003C/p>\n\u003Cp>And Express 5 fixed the two old complaints. Async errors in handlers now reach your error middleware without a wrapper, and the route matcher was rewritten (\u003Ccode>path-to-regexp\u003C/code> 8), with stricter syntax for wildcards. If you avoided Express because of \u003Ccode>express-async-errors\u003C/code>, that reason is gone.\u003C/p>\n\u003Ch2>Moving an Express app to Fastify\u003C/h2>\n\u003Cp>\u003Ccode>@fastify/express\u003C/code> (4.0.14, published November 26) lets Fastify run Express middleware, so you can move route by route. I&#39;d only do it for a reason: you want response schemas because of a data-leak scare, or the team keeps fighting the middleware order. &quot;It&#39;s faster&quot; isn&#39;t one. Profile first; the slow part is nearly always a query, an N+1 loop or a missing index, and switching frameworks fixes none of those.\u003C/p>\n\u003Ch2>How I&#39;d decide\u003C/h2>\n\u003Cp>If I&#39;m starting a new Node API that several people will work on for years, and it&#39;s mostly JSON in and JSON out, I&#39;d take Fastify for the schemas and the plugin scoping. If it&#39;s an existing Express codebase, a quick internal tool, or something leaning on Express-only middleware, Express 5.\u003C/p>\n\u003Cp>If you have a Node backend that&#39;s grown into something nobody wants to touch, or you&#39;re picking the stack for a new one and want a second opinion, \u003Ca href=\"https://calendly.com/director-norsky/meeting\">book a free call\u003C/a>. All consultation is free, and here&#39;s what I do for \u003Ca href=\"/services/nodejs-development\">Node.js backends\u003C/a>.\u003C/p>\n",[16],{"slug":17,"title":18,"description":19},"hono-vs-express","Hono vs Express: Which One I'd Start a Node API With in 2026","Hono vs Express in November 2026: Hono 4.13 with zero dependencies vs Express 5.3 with 64, where each runs, what breaks when you switch, and which to pick.",1795910047384]